5 Replies Latest reply on Aug 18, 2009 11:27 PM by Julien Kronegg

    Warning when using Seam FacesMessages and the h:messages tag

    Dan Dosch Newbie

      Does anyone know how to make the following warning go away.


      I am using the Seam FacesMessages component.


      import org.jboss.seam.faces.FacesMessages;
      .
      .
      .
      @In FacesMessages facesMessages;
      .
      .
      .
      facesMessages.add("Message");
      



      On the display page I just use the messages tag


      <h:messages />
      




      Whenever the backing bean sends a message a warning is logged.


      2008-09-12 15:59:58,216 WARN  [javax.enterprise.resource.webcontainer.jsf.renderkit] 'for' attribute cannot be null
      
      
      



      I believe the reason this warning occurs is because the h:messages tag gets turned into one or more h:message tags. The h:message tag requires an attribute called 'for'


      http://www.jsftoolbox.com/documentation/help/12-TagReference/html/h_message.html


      I have a feeling that the Seam implementation of FacesMessages doesn't give a value for the 'for' attribute, and so it throws this warning.


      Is there a way to fix this?


      Thanks,
      Dan

        • 1. Re: Warning when using Seam FacesMessages and the h:messages tag
          Daniel Hinojosa Master

          I believe that


          <h:messages globalOnly="true"/>
          



          will serve you well.

          • 2. Re: Warning when using Seam FacesMessages and the h:messages tag
            Dan Dosch Newbie

            I've tried both ways and the warning is thrown with and without the globalOnly attribute.

            • 3. Re: Warning when using Seam FacesMessages and the h:messages tag
              Oleg Novikov Newbie

              It was another reason for "'for' attribute cannot be null" by me:


              <s:decorate id="orderStatusDecoration" template="layout/edit.xhtml">
                      <ui:define name="label">Order status:</ui:define>
                      <h:inputText id="os1" value="not requested" rendered="#{travelHome.instance.orderStatus.equals('1')}"/>
                      <h:inputText id="os2" value="requested" rendered="#{travelHome.instance.orderStatus.equals('2')}"/></s:decorate>




              if orderStatus was neither 1 nor 2, it was nothing to render within template as a second element.


              The message "'for' attribute cannot be null" is disappeared, as i have added the third line inputText as follows:



              <s:decorate id="orderStatusDecoration" template="layout/edit.xhtml">
                      <ui:define name="label">Order status:</ui:define>
                      <h:inputText id="os1" value="not requested" rendered="#{travelHome.instance.orderStatus.equals('1')}"/>
                      <h:inputText id="os2" value="requested" rendered="#{travelHome.instance.orderStatus.equals('2')}"/>
                      <h:inputText id="os3" value="" rendered="#{empty travelHome.instance.orderStatus}"/></s:decorate>




              That assured (in my example only, where orderStatus is '' or 1 or 2 only), that the second element of the template always exists. And the annoying "'for' attribute cannot be null" is gone ;-)
                     

              • 4. Re: Warning when using Seam FacesMessages and the h:messages tag
                Julien Kronegg Novice

                We had the same issue as Oleg with the following code:


                <s:decorate id="fieldDecoratorId" template="layout/edit.xhtml">
                     <ui:define name="label">Field Name</ui:define>
                     <h:outputText id="fieldId" value="#{myBean.myValue}" />
                </s:decorate>


                                    
                Short story: the error was on our side: the template name to use is display.xhtml and not edit.xhtml, since the included element is not an input field.


                Long story: the edit.xhtml template has a <s:validateAll> tag which recursively looks for EditableValueHolder in included children. Since the <h:outputText> is not an EditableValueHolder, there is nothing to validate. This is the same cause as for Oleg's case when there was no <h:inputText>.


                While this is not clearly a bug, the <s:validateAll> tag may issue a warning if there is nothing to validate. Worth a feature request on JIRA? I'm not sure...