2 Replies Latest reply on Apr 1, 2009 8:11 PM by jeremygood

    invalid from "old" edit.xhtml with richfaces.

    tony.herstell1

      Using the non richFaces way of doing things we were able to automagically get access to the invalid variable; in this case to set the border round the component red...
      However moving to a Rich way of working:


      specifically not using

      <s:message styleClass="edit_template_error error" />


      as used in



      <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
              xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
              xmlns:s="http://jboss.com/products/seam/taglib">
      
              <div class="edit_template_area">
                      <span class="edit_template_non_hint_area">
                              <span class="edit_template_non_error_area">
                                      <span class="edit_template_label_area">
                                              <s:label styleClass="#{invalid?'error':''}">
                                                      <ui:insert name="label" />
                                              </s:label>
                                      </span>
      
                                      <span class="edit_template_hint_area">
                                              <ui:insert name="hint"/>
                                      </span>   
      
                                      <span class="edit_template_content_area #{invalid?'errorblock':'noerrorblock'}">
                                              <s:validateAll>
                                                      <ui:insert name="content" />
                                              </s:validateAll>
                                      </span>
              
                                      <span class="edit_template_tag_area">
                                              <h:outputText styleClass="mandatory" value="#{messages.general_mandatory_tag}" rendered="#{required}"/>
                                      </span>
                              </span>
      
                              <span class="edit_template_error_area">
                                      <center>
                                              <s:message styleClass="edit_template_error error" />
                                      </center>
                              </span>
                      </span>
      
              </div>
      </ui:composition>




      but instead using


      <rich:message id="messageTextErrorMessages" errorClass="error" warnClass="warn" infoClass="info" for="messageText"/> 

      it appears that the invalid variable is not automagically set.


      How has this been done now?



      <a4j:outputPanel id="messageTextInputPanel">
              <div>
                      <span>
                              <h:inputTextarea class="#{invalid?'errorblock':'noerrorblock'}" id="messageText" value="#{messageText}" cols="68" rows="30" required="true"/>
                      </span>
                      <span>
                              <rich:message id="messageTextErrorMessages" errorClass="error" warnClass="warn" infoClass="info" for="messageText"/> 
                      </span>
              </div>
      </a4j:outputPanel>
      



      class="#{invalid?'errorblock':'noerrorblock'}"

      invalid is not being set now!

        • 1. Re: invalid from "old" edit.xhtml with richfaces.
          tony.herstell1

          RTFM



          
          29.1.3. Formatting
          29.1.3.1. <s:decorate>
          ...
          #{invalid} and #{required} are available inside s:decorate; #{required} evaluates to true
          if you have set the input component being decorated as required, and #{invalid} evaluates to
          true if a validation error occurs.

          • 2. Re: invalid from "old" edit.xhtml with richfaces.
            I am using s:decorate, but the invalid context variable DOES NOT GET SET on ajax validation, only on form submit.

            In my example, the error message gets displayed when the field loses focus, but the field name does not turn red, and the error.gif doesn't show up until form submission. The error message is tied to the ajax validation, but the other two display items are tied to the #{invalid} context variable.

            Any thoughts?