2 Replies Latest reply on Feb 19, 2008 4:17 PM by tomstrummer.tomstrummer.gmail.com

    Non-rendering s:decorate component

    tomstrummer.tomstrummer.gmail.com

      Can I get the s:decorate tag to not render a <div> around its children?  The reason being, I want to keep my form fields in a table so that labels/ inputs align correctly without resorting to explicit widths on floated divs.


      But I can't use a table (or panelGrid) if I use the s:decorate tag around my label+input because it wraps them in a <div> element which messes things up.


      Here's what I'm trying to do...


      <h:form>
        <table>
          <s:decorate template='../layout/edit-table.xhtml'>
            <ui:define name='label'>Name:</ui:define>
            <h:inputText id='pName' value='#{person.name}' required='true'/>
          </s:decorate>
      
          <!-- other form fields w/ same decoration... -->
      </h:form>



      And then the template looks like this:


      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                      xmlns:ui="http://java.sun.com/jsf/facelets"
                      xmlns:s="http://jboss.com/products/seam/taglib">
      
        <tr class="field #{invalid?'error':''}">
      
          <th>
            <s:label styleClass="name">
              <ui:insert name="label" />
            </s:label>
            <s:span styleClass="required" rendered="#{required}">*</s:span>
          </th>
           
          <td class="value">
            <s:validateAll>
              <ui:insert/>
            </s:validateAll>
          </td>
      
          <td>
            <s:message styleClass="errorMsg" />
          </td>
                
        </tr>
      </ui:composition>



      So this would work brilliantly if only I could cross s:decorate and s:fragment...  Any suggestions?


      Thanks. 

        • 1. Re: Non-rendering s:decorate component
          pmuir
          • 2. Re: Non-rendering s:decorate component
            tomstrummer.tomstrummer.gmail.com

            Thank you.


            I solved this by just decorating the field and leaving the label like so:


                 <h:panelGrid columns='2'>
                      <h:outputLabel for='name' value='Name:' />
                      <s:decorate template='../layout/edit-tr.xhtml'>
                           <h:inputText id='name' value='#{deviceConfig.name}' required='true'/>
                      </s:decorate>
            ...
            



            And the template (edit-tr.xhtml)


            <ui:composition  xmlns="http://www.w3.org/1999/xhtml"
                             xmlns:ui="http://java.sun.com/jsf/facelets"
                             xmlns:s="http://jboss.com/products/seam/taglib">
            
                 <s:validateAll>
                      <ui:insert/>
                      <s:message styleClass="error errLabel" />
                 </s:validateAll>
            </ui:composition>