13 Replies Latest reply on Feb 26, 2008 1:23 PM by pmuir

    Tuning validation for information

    nickarls

      Is there a way of specifying different facets for different levels of component messages?


      Something like a separate

      <f:facet name="aroundInfoField>...

      that would be used if the component had only info-level messages. Could be user e.g. for displaying and info-graphics.


      Or there could be attributes for

      <s:decorate errorTemplate="..." infoTemplate="...">...



      Is it even possible to do currently without duplicating too much view code? Can you access the component somehow in s:decorate so that you can decide what template to use based on if the component has info or error messages?


      Enough interest to justify a JIRA?

        • 1. Re: Tuning validation for information
          christian.bauer

          I don't think this is really necessary. For example, on this site we do not use a different template for each message severity, but one for informational and one for anything worse than info that needs more attention. So this check works just fine:


          <h:panelGrid styleClass="messageBoxTable" columns="2" cellpadding="0" cellspacing="0" border="0"
                       rendered="#{message.severity.ordinal == 0}">
                  <h:graphicImage value="#{themePath}/img/info.gif"
                                  width="18" height="18"
                                  styleClass="infoImage"/>
                  <h:outputText styleClass="infoMessage" value="#{message.summary}"/>
          </h:panelGrid>
          
          <h:panelGrid styleClass="messageBoxTable" columns="2" cellpadding="0" cellspacing="0" border="0"
                       rendered="#{message.severity.ordinal > 0}">
              <h:graphicImage value="#{themePath}/img/attention.gif"
                              rendered="#{message.severity.ordinal > 0}"
                              width="18" height="18"
                              styleClass="attentionImage"/>
              <h:outputText styleClass="attentionMessage" value="#{message.summary}"/>
          </h:panelGrid>
          

          • 2. Re: Tuning validation for information
            gavin.king

            I don't really like the idea of having multiple templates, since I think the only thing that would vary between them would be one css class. Also it gets verbose at the point of use.



            Christian, why did you not write your template like this:



            <h:panelGrid styleClass="messageBoxTable" columns="2" cellpadding="0" cellspacing="0" border="0"
                          rendered="#{invalid}>
                    <h:graphicImage value="#{themePath}/img/info.gif"
                                    width="18" height="18"
                                    styleClass="#{message.severity.ordinal == 0 ? 'info':'attention'}Image"/>
                    <h:outputText styleClass="#{message.severity.ordinal == 0 ? 'info':'attention'}Message" 
                                  value="#{message.summary}"/>
            </h:panelGrid>



            That's much less verbose...

            • 3. Re: Tuning validation for information
              gavin.king

              I mean one css class and one image :-)

              • 4. Re: Tuning validation for information
                christian.bauer

                I guess I had very different HTML for different levels, at some point. We could probably clean it up now, but that's true for many other things :)


                • 5. Re: Tuning validation for information
                  nickarls

                  Thanks for the replies.


                  is s:decorate supposed to expose the message as #message.severity.ordinal}? The original question was regarding component level messages, are the suggestions still applicable?


                  Should I be able to place a s:decorate around my field with the applied template containing an afterInvalidField facet containing your code?


                  BTW Chris, do you also have a baseball cap with <HEAD>? ;-) ref: avatar

                  • 6. Re: Tuning validation for information
                    nickarls

                    Shameless bump. Yeah, yeah, I know, I'm spoiled...

                    • 7. Re: Tuning validation for information
                      christian.bauer

                      That's a good way to never get a response again from any of us, too :)

                      • 8. Re: Tuning validation for information
                        nickarls

                        Christian Bauer wrote on Feb 13, 2008 11:12 PM:


                        That's a good way to never get a response again from any of us, too :)


                        Hey, give me some credit, at least I'm honest! ;-)

                        • 9. Re: Tuning validation for information
                          nickarls

                          looking at the wiki code I now see that the #{message} in your example was bound to #{facesMessages.currentGlobalMessages} but is there any way to hook into the messages for a component (for use in the invalid-facets)?


                          s:message seems to be able to do it. or is it force-fed by the s:decorate?

                          • 10. Re: Tuning validation for information
                            nickarls

                            If I get a nice solution to this I'll document it in the knowledge base and write the Web Beans RI for you. Well, at least the first one...

                            • 11. Re: Tuning validation for information
                              pmuir

                              Thats something Christian did using the alias you found - not something <s:decorate /> gives you - you could file a feature request for <s:decorate /> to give you this, it's not a bad idea.

                              • 12. Re: Tuning validation for information
                                nickarls

                                So the interpretation is "there is currently no way to access the list of messages for a specific component from an e.g. aroundInvalidField facet in EL"?

                                • 13. Re: Tuning validation for information
                                  pmuir

                                  No AFAICS.