0 Replies Latest reply on Dec 18, 2014 9:37 AM by jorei

    Richfaces Datatable loses submitted value of inputs on validation fail

    jorei

      Hi there,

      I recently posted the below question on Stackoverflow, but didn't get an answer. Unfortunately I'm still stuck with this and don't see how to work around it. Maybe somebody here can help. (Also feel free to answer on SO to claim a few points )

      I have two inputs - one inside a "normal" h:dataTable and one inside a rich:dataTable When I submit a wrong value, i.e. validation fails, the "normal" one keeps the value I submitted while the second one loses it. See the following code snippets (enter any value an press the button) We're using Richfaces 4.3.7. Is there a way to make it behave the same way the normal JSF-DataTable does? Using h:dataTable instead is not an option for us and losing your "I-was-just-about-to-correct-it" input is rather annoying.

      ManagedBean

      @ManagedBean

      @ViewScoped

      public class TestController {

          private String someInputValue; // + Getter, Setter

          private String[] stringArray = {"Element 1"}; // + Getter

       

          public void doSomething() {

              System.out.println("Did something");

          }

       

       

          public void validate(FacesContext facesContext, UIComponent uiComponent, Object value) throws ValidatorException {

              throw new ValidatorException(new FacesMessage("This can never be valid."));

          }

      }

       

      View

           <h:form id="form1">

                  <h1>h:dataTable</h1>

                  <h:dataTable value="#{testController.stringArray}" var="string">

                      <h:column>

                          <h:outputText value="#{string}:"/>

                          <h:inputText id="someInput" value="#{testController.someInputValue}" validator="#{testController.validate}"/>

                          <h:message for="someInput" id="msg" style="color: red;"/>

                      </h:column>

                  </h:dataTable>

       

       

                  <h:commandButton action="#{testController.doSomething}" value="do something"/>

              </h:form>

       

              <h:form id="form2">

                  <h1>rich:dataTable</h1>

                  <rich:dataTable value="#{testController.stringArray}" var="string">

                      <h:column>

                          <h:outputText value="#{string}:"/>

                          <h:inputText id="someInput" value="#{testController.someInputValue}" validator="#{testController.validate}"/>

                          <h:message for="someInput" id="msg" style="color: red;"/>

                      </h:column>

                  </rich:dataTable>

       

       

                  <h:commandButton action="#{testController.doSomething}" value="do something"/>

              </h:form>