title: Navigating to anothers pages in JSF 2.2 sending parameters
body: <p>I have a commandButton that I will use to navigate and send a parameter to another page (the id of the selected object so I will be able to load the entire object in the other page after retrieving it from the database). I know that commandButtons use POST as request method and that it isn't a good practice for navigation, but in my tests I was close to the expected results using it instead of any other methods.</p>
  
  <p>The code of my commandButton is something like this:</p>
  
  <pre><code>&lt;p:commandButton value="Start" action="#{startBean.goToNextPage()}"&gt;
      &lt;f:param name="objectId" value="#{startBean.object.Id}"/&gt;
  &lt;/p:commandButton&gt;
  </code></pre>
  
  <p>The problem happens on page load (specifically when the commandButton is rendered), because  executes before the object be set, when the navigation occurs the parameter is sent to the other with 'null' value.</p>
  
  <p>So, I'd like to know how I can set the  'value' only when click on the commandButton, or other ways to navigate to the other page sending parameters, in this specific case it might be using GET or POST.</p>
  
  <p>Thanks in advance!</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I'll detail what I'm really trying to do.
  I'm trying to send a simple parameter (an object id) as POST or GET while navigating to another page. I tried first with <code>&lt;p:commandButton /&gt;</code> for stylish reasons. The action attribute of the commandButton calls  a method from managedBean that returns the url which it should navigate to. The <code>goToNextPage()</code> looks like:</p>
  
  <pre><code>public String goToNextPage(){
      String url = "nextPage.xhtml?" + "faces-redirect=true&amp;objectId=" + this.object.getId();
      return url;
  }
  </code></pre>
  
  <p>After the <code>gotToNextPage()</code> method the <code>@PostConstruct</code> of the nextPageBean runs and I'm able to read the parameter sent using <code>FacesContext#getRequestParameterMap()</code>, the navigation doesn't complete, and the page just refresh.</p>
  
  <p>So I'd like to know how I should send parameters to another page and navigating to it using GET or POST.</p>