2 Replies Latest reply on Feb 3, 2008 4:17 PM by Pete Muir

    ui:insert and setting values

    Eric H Novice

      Simple question: I'm defining a template which I want to display one of the defined items twice. For example, here's what the template looks like:

      <ui:composition>
       <h2>Here it is the first time:</h2>
       <ui:insert name="groupA"/>
       <h2>And now we see it again:</h2>
       <ui:insert name="groupA"/>
      </ui:composition>


      And that works correctly. Next step, I would like to have different settings within the template when I run it the second time. For example:

      The file using the template:
      (Some stuff)
      
      <ui:decorate template="/my-template.xhtml">
      
       <ui:define name="groupA">
       This content shows up always!
      
       <s:div rendered="{showFirstTime}">
       This div will show only when showFirstTime is true
       </s:div>
      
       <s:div rendered="{showSecondTime}">
       This div will show only when showFirstTime is true
       </s:div>
       </ui:define>
      </ui:decorate>
      
      (some more stuff)


      Then I would like to make the template look like this:

      <ui:composition>
       <h2>Here it is the first time:</h2>
      
       <ui:insert name="groupA">
       <ui:param name="showFirstTime" value="#{true}"/>
       <ui:param name="showSecondTime" value="#{false}"/>
       </ui:insert>
      
       <ui:insert name="groupA">
       <ui:param name="showFirstTime" value="#{false}"/>
       <ui:param name="showSecondTime" value="#{true}"/>
       </ui:insert>
      
       <h2>And now we see it again:</h2>
       <ui:insert name="groupA"/>
      </ui:composition>


      But that doesn't work. The value set by ui:param doesn't show up.

      Any ideas on how to do this? I'm obviously missing something with Facelets here. Is there some tag to set a value in the page context? That seems like what I want to do, but <ui:param> (and f:param) don't do it.

      Thanks