3 Replies Latest reply on Jul 14, 2009 2:36 PM by wvreeven

    Update s:decorate's 'invalid' form attr on AJAX update

      My forms use s:decorate around all form fields (as per the Seam documentation), and highlight the form field when invalid, based on the value of #{invalid} variable.

      Let's say I previously attempted to submit the form with invalid values, so now some form fields are highlighted as invalid. Then I use AJAX to insert new values into the fields - (e.g. click a record in a table and have its values appear for editing in the form fields).

      The fields which were previously invalid are still showing highlighted as invalid, even though the current values aren't invalid. I've got an a4j:outputPanel with ajaxRendered set to true around the whole a4j:form. Somehow #{invalid} needs to be either reset or reevaluated.

      How can I get around this issue?

        • 1. Re: Update s:decorate's 'invalid' form attr on AJAX update
          Interesting, this is exactly the reverse of what I am trying to figure out. I want to know why the #{invalid} context variable does not get set when ajax validation finds an error.

          Using <a4j:support> and an <a4j:outputPanel>, I am able to get error messages to print out when a field loses focus, but I have an error.gif image that does not show up until the form is submitted. The error image has rendered="#{invalid}". Also, the name of the field should turn red, which it does on form submit, but not when the field loses focus. Again, this is triggered by the "#{invalid}" context variable.

          So, it would appear that the "#{invalid}" context variable does NOT get set by the ajax field validator.

          Any thoughts?
          • 2. Re: Update s:decorate's 'invalid' form attr on AJAX update

            Hi Kris (Veer?),

            We are running into a similar issue as you. Did you ever resolve this? FYI I am trying to resolve this next situation:

            We have a form that is populated with data from an entity instance. If our Save button is clicked some fields get validated. If they are invalid, they appear highlighted and a message is displayed stating what's wrong. If we then fill the form with data from another Entity (by selecting another node in a tree) only the invalid fields get rerendered. I'd like to know how to also reset the other fields. Perhaps your solution may be of help to me.

            Thanks, Wouter

            • 3. Re: Update s:decorate's 'invalid' form attr on AJAX update

              Took me a while but I found a solution. Posting it here so others may benefit from it as well. This MyFaces page


              gives info on how to clear forms and inputs. We are using the getChildren().clear() method now.

              Thanks, Wouter