6 Replies Latest reply on Mar 30, 2016 12:08 PM by Franck Gasparotto

    What is the expected result when using @resetValues on this simple example ?

    Franck Gasparotto Newbie

      Hello,

      According to the next exemple launched on RF 4.5.14 / MyFaces 2.2.9, what is the expected result on step 2 ?

      • Step 1 : empty the input field and click save
        Result : the required message appears
      • Step 2 : click the 2nd button "Change Info1 Value"
        Result : In my opinion, it should show "Changed Value" into the field, but it keeps the previous value when rendering. Am I wrong ?

       

      Thanks for your help.

       

      Facelet code :

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
      <html
          xmlns="http://www.w3.org/1999/xhtml"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:ui="http://java.sun.com/jsf/facelets"
          xmlns:a4j="http://richfaces.org/a4j"
          xmlns:rich="http://richfaces.org/rich"
          xmlns:mcc="http://myfaces.apache.org/commons/converters">
      <h:head>
          <title>Test reset values</title>    
      </h:head>
      <h:body>
          <h:form id="f1">
              <rich:messages id="msg" />
              <h:outputLabel value="Info 1" for="itInfo1" /><h:inputText id="itInfo1" value="#{testBean.info1}" required="true" label="Info 1" />
              <a4j:commandButton value="save" />
              <a4j:commandButton value="change Info1 Value" execute="@this" action="#{testBean.changeInfo1Value}" render="itInfo1" resetValues="true"/>
          </h:form>
      </h:body>
      </html>
      

       

       

      Java code :

       

      import javax.faces.bean.ManagedBean;
      import javax.faces.bean.ViewScoped;
      
      @ManagedBean
      @ViewScoped
      public class TestBean {
          private String info1 = "info1";
          
          public TestBean() {
          }
      
          public String changeInfo1Value() {
              info1 = "Changed Value";
              return null;
          }
      
          public String getInfo1() {
              return info1;
          }
      
          public void setInfo1(String info1) {
              this.info1 = info1;
          }
      
      }