title: How to use RequestContext in primefaces?
body: <p>I'm new to primefaces. I trying some examples in <a href="http://www.primefaces.org/showcase-labs/ui/callbackParams.jsf" rel="nofollow">primeface showcase</a></p>
  
  <p><strong>But;</strong></p>
  
  <p>After <code>saveUser</code>, on ajax method <code>handleComplete(xhr, status, args)</code> args don't have arguments that added in <code>saveUser</code> method. </p>
  
  <p><strong>EDIT</strong> : I just added <code>@ManagedBean</code> annotations because i'm using jsf 2.0</p>
  
  <p><strong>EDIT-2</strong></p>
  
  <p>in my pom;</p>
  
  <pre><code>        &lt;dependency&gt;
              &lt;groupId&gt;org.primefaces&lt;/groupId&gt;
              &lt;artifactId&gt;primefaces&lt;/artifactId&gt;
              &lt;version&gt;2.2&lt;/version&gt;
          &lt;/dependency&gt;
  </code></pre>
  
  <p>in my web.xml</p>
  
  <pre><code>&lt;servlet&gt;
          &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
          &lt;servlet-class&gt;javax.faces.webapp.FacesServlet&lt;/servlet-class&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
  
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;*.xhtml&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>in my .xhtml page</p>
  
  <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.prime.com.tr/ui"&gt;
  
  &lt;h:head&gt;
  
      &lt;script type="text/javascript"&gt;  
          function handleComplete(xhr, status, args) {  
              if(args.validationFailed) {  
                  alert("Validation Failed");  
              } else {  
                  alert("Save:" + args.saved);  
                  alert("FirstName: " + args.user.firstname + ", Lastname: " + args.user.lastname);   
              }  
          }  
      &lt;/script&gt; 
  
  &lt;/h:head&gt;
  &lt;h:body&gt;
  &lt;h:form&gt;
      &lt;p:panel id="panel" header="New User"&gt;
          &lt;h:panelGrid columns="2"&gt;
              &lt;h:outputLabel for="firstname" value="Firstname: *" /&gt;
              &lt;p:inputText id="firstname" value="#{user.firstName}" required="true"/&gt;
  
              &lt;h:outputLabel for="surname" value="Lastname: *"  /&gt;
              &lt;p:inputText id="surname" value="#{user.surName}" required="true"/&gt;
          &lt;/h:panelGrid&gt;
      &lt;/p:panel&gt;
  
      &lt;p:commandButton value="Save" actionListener="#{user.saveUser}" oncomplete="handleComplete(xhr, status, args)" /&gt;
  &lt;/h:form&gt;
  
  
  &lt;/h:body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>in my bean;</p>
  
  <pre><code>@ManagedBean(name = "user")
  public class User {
  
      private String firstName = "";
      private String surName = "";
  
      public void setFirstName(String firstName) {
          this.firstName = firstName;
      }
  
      public String getFirstName() {
          return firstName;
      }
  
      public void setSurName(String surName) {
          this.surName = surName;
      }
  
      public String getSurName() {
          return surName;
      }
  
      public void saveUser(ActionEvent actionEvent) {
          // save user
          RequestContext context = RequestContext.getCurrentInstance();
          context.addCallbackParam("saved", true);
          context.addCallbackParam("user", this);
      }
  
  }
  </code></pre>
  
  <p><strong>EDIT -3</strong></p>
  
  <p>I can catch properties that carried with data in ajax response with <code>this.PrimeFaces.ajax.RequestManager.requests[0].data</code> it carries that data ;</p>
  
  <pre><code>"j_id2059540600_7ac21836=j_id2059540600_7ac21836&amp;j_id2059540600_7ac21836%3Afirstname=qweq&amp;j_id2059540600_7ac21836%3Asurname=asda&amp;javax.faces.ViewState=8900392402396831372%3A-8139730777939772917&amp;javax.faces.partial.ajax=true&amp;javax.faces.source=j_id2059540600_7ac21836:j_id2059540600_7ac218a5&amp;javax.faces.partial.execute=@all&amp;j_id2059540600_7ac21836:j_id2059540600_7ac218a5=j_id2059540600_7ac21836:j_id2059540600_7ac218a5"
  </code></pre>
  
  <p>But i'm pretty sure there is another option. Just can't seet it.</p>
  
  <p>Thanks for any help.</p>