3 Replies Latest reply on Dec 27, 2007 4:40 AM by marinew

    Rerender after validation errors

    dencel

      The problem is that an input component will not rerender after a validation error occured.

      Example code:

      <a4j:commandButton action="validate" value="validate"/>
      <a4j:region>
       <h:inputText>
       <a4j:support action="#{testView.doTest}" event="onkeyup" reRender="test"/>
       </h:inputText>
      </a4j:region>
      <h:inputText value="#{orderView.test}" required="true" id="test">
       <f:validateLength minimum="2"/>
      </h:inputText>
      


      Handling 1(works): type something in first textbox, validation is ignored,:test is rerendered everything works.
      Handling 2: click validate button, and try handling 1. :test doesn't get updated.

      My question is: how do you people handle this problem? I think the only way is to reset the submitted and local value of UIInput using component binding, but I don't like this approach.

      Can anybody help me?

        • 1. Re: Rerender after validation errors
          ilya_shaikovsky

          Sorry but not sure that understand your clearly.

          As I understood - if you press a button - validation fails - so no new value will be applied and old one will be shown. It's right.

          If I miss something - describe detailed step by step what you need to see and what happened.

          • 2. Re: Rerender after validation errors
            dencel

             

            "ilya_shaikovsky" wrote:

            As I understood - if you press a button - validation fails - so no new value will be applied and old one will be shown. It's right.


            I am sorry, you are missing a key part.
            public void doTest()
            {
             this.test="you are now valid";
            }
            

            Situation 1: you type something in field 1 and field2 shows "you are now valid"
            Situation 2: button gets clicked, validation fails, you type something in field 1, the model gets updated, but field 2 remains blank.

            I've solved this by itterating through the viewroot and setting the submittedvalues of UIInput elements to null. But I don't think this is a nice solution.


            • 3. Re: Rerender after validation errors
              marinew

              Hello,

              I had the same problem, and found a cleanre solution, I think. See my post here : http://jboss.com/index.html?module=bb&op=viewtopic&p=4115655#4115655