5 Replies Latest reply on Aug 18, 2008 2:39 AM by Chris Simons

    Could s:decorate provide a component id?

    Adrian Mitev Master

      I have to set sane labels for all controls on the page (requirement by the QA team). For this purpose i have to define id's in the template used by s:decorate. Does s:decorate provide something like this


      <div class="prop">
          <s:label id="#{compId}Label" styleClass="name #{invalid?'errors':''}">
              <ui:insert name="label"/>
              <s:span id="#{compId}Required" styleClass="required" rendered="#{required}">*</s:span>
          </s:label>
      
          <span class="value #{invalid?'errors':''}">
              <s:validateAll>
                  <ui:insert/>
              </s:validateAll>
          </span>
      
           <span class="error">
               <h:graphicImage value="/img/error.gif" rendered="#{invalid}" styleClass="errors"/>
               <s:message id="#{compId}message" styleClass="errors"/>
           </span>
      </div>
      


      Take a look at #{compId}
      The only solution for now is to use


      <s:decorate template="/layout/edit.xhtml">
          <ui:define name="label">User Name</ui:define>
          <h:inputText id="userName" value="#{user.Name}" />
          <ui:param name="compId" value="userName" />
      </s:decorate>
      

        • 1. Re: Could s:decorate provide a component id?
          Francisco Jose Peredo Noguez Master

          Hi!


          I just want to say that adding labels to all controls on the page just because it is a requirement by the QA team is the kind of thing that makes me really sad... it is just silly... the kind of stuff QA asks without understanding its real purpose.


          I think labeling stuff you actually interact with is very important, without that it becomes really hard to know what are you getting from Label234.getText(), but <s:decorate> is like an include directive, one already knows what it is fore because of the template="/layout/edit.xhtml", imagine if it were mandatory to add an id to every import declaration in a .java (I hope you agree that would be silly):


          
          import java.lang.* id=foundation java stuff
          import javax.sql.* id=sql extensions for java
          
          



          I even think that adding it as a comment would be a bad idea, the name of the package should be self explaining, if it is not, then what should be fixed is the name of the package, in the case of s:decorate the name of the template should be carefully selected, so that is really clear what it is for, but there is no need to add an artificial id just because QA wants it.


          Regards,

          • 2. Re: Could s:decorate provide a component id?
            Chris Simons Expert

            As far as I know, and we are using s:decorate, there is no way to automatically introspect the ID of the component that is including the s:decorate template.


            However, we are doing much the same thing as you are by supplying various ui:params that can provide useful information for the purposes of s:decorate.  I think you are going about this in the right way.  Perhaps you could add a feature request in JIRA for the Seam team to enhance the decorate template with some new capabilities.  For now, however, the ability of s:decorate to automatically detect JSF validation errors is quite a boon.


            A few that we are including, for example:



            1. colspan

            2. tooltip text

            3. an is applicable boolean and an altternate text in the case that is applicable is false



            • 4. Re: Could s:decorate provide a component id?
              Adrian Mitev Master

              Actually this isn't needed since s:decorate implements NamingContainer.

              • 5. Re: Could s:decorate provide a component id?
                Chris Simons Expert

                Adrian,


                Can you please elaborate on your statement above?