7 Replies Latest reply on Apr 10, 2014 5:09 AM by Michal Petrov

    How to reset form fields and rerender the form?

    Jiří Holuša Newbie

      Hi,

       

      I'm stuck at pretty simple task: I have a search form where the search criteria are stored is SearchCriteriaSession bean, so it could be remembered and pre-filled. And I want to add reset button to that form that would: 

      1) clear the criteria from bean, therefore call clearSearchCriteria() method of the bean
      2) rerender the form, so the fields would be empty

       

      Here's my code and I have no idea why it's not working:

       

      search.xhtml

      ... 
      <h:form id="criteriaForm">
      <div class="controls">
      <h:inputText type="text" id="testName" value="#handlingBean.criteria.testName}" />
      </div>

      //more input fields but with same format
       

      <
      div class="form-actions">
      <r:commandButton action="#searchCriteriaSession.clearSearchCriteria}" value="Reset" render="@form :criteriaForm" />
      </div>
      </h:form>
      ...

      The searchCriteriaSession.clearSearchCriteria just clears criteria. When I debug it I see it correctly cleared. Even when I refresh the page the form clears, so the problem is that the render attribute is not working correctly, I guess.

       

      Does anybody can please help me?

       

      P.S.: I'm using RichFaces, this maven artifact:

      <dependency> 
      <groupId>org.richfaces.compat</groupId>
      <artifactId>richfaces-components-rich</artifactId>
      <version>4.5.0.Alpha2</version>
      </dependency>