O'Reilly logo

PrimeFaces Beginner's Guide by K. Siva Prasad Reddy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – updating UI components using RequestContext.update()

In this section, we will demonstrate how to update client-side view components from the server side using the following steps:

  1. Create a form with an input field and a submit button as follows:
    <h:form id="form1">
      <h:panelGrid columns="2">
        <h:outputLabel value="EmailId" />
        <p:inputText id="emailId" value="#{requestContextController.emailId}"/>
        
        <p:commandButton id="submitBtn" value="Submit" actionListener="#{requestContextController.handleSubmit}" />
      </h:panelGrid>
      <h:outputText value="You have Entered : #{requestContextController.emailId}" />
    </h:form>
  2. In the action handler method, update the form component using the RequestContext.update() method as follows:
    public void handleSubmit(ActionEvent ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required