3 Replies Latest reply on Jul 25, 2007 12:24 PM by steve tynor

    <s:decorate> - is id available within template?

    steve tynor Novice

      Argh. I've changed my edit.xhtml to layout my form elements as table rows since I have some forms which need to be multi-column and getting fixed -width CSS to work properly is hard. It all displays fine now until I trigger an ajax4jsf validation/rerender -- then I start seeing duplicated rows in my table(!). This is probably a bug in ajax4jsf, but i don't have the energy to track it down - i just want to work around by causing the rerender to not trigger problems.

      If I add a named span inside my td and rerender that, it seems to work properly. However, I need to generate an id for that span based on the id passed to the s:decorate tag, but can't figure out how to do that.

      I've tried accessing the id via #{id} and by setting for= on the s:decorate and accesing it via #{forId} - both evaluate to empty strings in my template. I've looked at the Seam tag source and the facelets tag source and don't understand how or if the attribute values are propagated to EL. Help please!

      Seam 1.2.1-GA (what precise version of Facelets is bundled?)
      Richfaces 3.0.1
      Ajax4jsf 1.1.1

        • 1. Re: <s:decorate> - is id available within template?
          steve tynor Novice

          It may not be clear from my original text what i'm trying to do.

          I have various form elements that use <s:decorate>:

          <s:decorate id="cityDecoration" template="/WEB-INF/facelets/templates/edit.xhtml">
           <ui:define name="label">City</ui:define>
           <ui:param name="partialRequired" value="true" />
           <h:inputText id="city"
           size="40"
           maxlength="50"
           value="#{clientHome.instance.city}">
           <a:support event="onblur" reRender="cityDecorationINNER1,cityDecorationINNER2"/>
           </h:inputText>
           </s:decorate>


          in my edit.xhtml, i'd like to use the id passed to s:decorate (cityDecoration) and use it to name two spans:

          <tr class="entry"">
          <th class="name">
          <span id="#{id}INNER1">
           <s:label styleClass="name #{invalid?'errors':''}">
           <ui:insert name="label"/>
           <s:span styleClass="required" rendered="#{required}">*</s:span>
           </s:label>
          </span>
          </th>
          <td>
          <span id="#{id}INNER2">
           <span class="value #{invalid?'errors':''}">
           <s:validateAll>
           <ui:insert/>
           </s:validateAll>
           </span>
           <ui:insert name="description" />
           <div><s:message styleClass="error errors"/></div>
          </span>
          </td>
          </tr>


          I can't find a way to refer to the s:decorate's id to generate a derived name (#{id} as above doesn't work - it evaluates to an empty string). The only thing i can find that will work is to set a <ui:param> and use that instead of the s:decorate's id-- but that really clutters my form xhtml.


          • 2. Re: <s:decorate> - is id available within template?
            Christian Bauer Master

             


            The only thing i can find that will work is to set a <ui:param> and use that instead of the s:decorate's id-- but that really clutters my form xhtml.


            And that would be the only way how you can get a value into a scope that is resolvable via EL. The id just isn't available.

            • 3. Re: <s:decorate> - is id available within template?
              steve tynor Novice

              Thanks Christian,

              Knowing that will save me some from wasting more time on fruitless searching. I'll reconcile myself to adding <ui:param>'s :)