4 Replies Latest reply on Aug 10, 2007 12:45 PM by henrik.lindberg

    rich:togglePanel problems

    henrik.lindberg

      Hi,
      I have problems with the rich:togglePanel

      1. Nothing is rendered unless stateOrder is specified. It says in the documentation that initialState can be set instead. I would have expected that it used facets in the order they are specified starting with initialState if stateOrder is missing. But it doesn't.

      2. I can't get togglePanel to work with ui:repeat

      Here is an example that works:

       <rich:togglePanel
       id="panel"
       switchType="client"
       initialState="x_#{texts[0].id}"
       stateOrder="x_#{texts[0].id},x_#{texts[1].id}, x_#{texts[2].id}"
       >
       <f:facet name="x_#{texts[0].id}">
       <h:panelGroup>
       <f:verbatim>
       <p>some text 0</p>
       </f:verbatim>
       </h:panelGroup>
       </f:facet>
       <f:facet name="x_#{texts[1].id}">
       <h:panelGroup>
       <f:verbatim>
       <p>some text 1</p>
       </f:verbatim>
       </h:panelGroup>
       </f:facet>
       <f:facet name="x_#{texts[2].id}">
       <h:panelGroup>
       <f:verbatim>
       <p>some text 2</p>
       </f:verbatim>
       </h:panelGroup>
       </f:facet>
       </rich:togglePanel>
       <rich:toggleControl for="#{containerName}:panel" value="next..." />
      

      If I remove the stateOrder attribute, nothing is rendered.
      If, instead of listing the facets I do the following:
       <h:form id="#{containerName}" >
       <rich:togglePanel
       id="panel"
       switchType="client"
       initialState="x_#{texts[0].id}"
       stateOrder="x_#{texts[0].id},x_#{texts[1].id}, x_#{texts[2].id}"
       >
       <ui:repeat value="#{texts}" var="t" >
       <f:facet name="x_#{t.id}">
       <h:panelGroup>
       <f:verbatim>
       <p>some text for #{t.id}</p>
       </f:verbatim>
       </h:panelGroup>
       </f:facet>
       </ui:repeat>
       </rich:togglePanel>
       <rich:toggleControl for="#{containerName}:panel" value="next..." />
       </h:form>
      

      I get an error that the mentioned state "x_34" does not exist. Which leads me to think that ui:repeat was not executed.

      If I remove the stateOrder - I do not get the error, but it also does not render anything.

      It would be very useful to be able to use ui:repeat to produce the facets. Shouldn't this work?


        • 1. Re: rich:togglePanel problems
          henrik.lindberg

          a4j:repeat gives the same result as ui:repeat btw.

          • 2. Re: rich:togglePanel problems
            henrik.lindberg

            This horrible construction is what I ended up with - not very flexible as I have to hard-code the number of facets.

             <h:form id="#{containerName}" >
             <rich:togglePanel
             id="panel"
             switchType="client"
             initialState="x_#{texts[0].id}"
             stateOrder="x_#{texts[0].id},x_#{texts[1].id}, x_#{texts[2].id}, x_#{texts[3].id}, x_#{texts[4].id}"
             >
             <f:facet name="x_#{texts[0].id}">
             <h:panelGroup>
             <h:outputText styleClass="#{textStle}" value="#{texts[0].digest}" />
             <rich:toggleControl for="#{containerName}:panel"
             value="next..."
             switchToState="x_#{texts.size() gt 1 ? texts[1].id : texts[0].id}"
             />
             </h:panelGroup>
             </f:facet>
             <f:facet name="x_#{texts[1].id}">
             <h:panelGroup>
             <h:outputText styleClass="#{textStle}" value="#{texts[1].digest}" />
             <rich:toggleControl for="#{containerName}:panel"
             value="next..."
             switchToState="x_#{texts.size() gt 2 ? texts[2].id : texts[0].id}"
             />
             </h:panelGroup>
             </f:facet>
             <f:facet name="x_#{texts[2].id}">
             <h:panelGroup>
             <h:outputText styleClass="#{textStle}" value="#{texts[2].digest}" />
             <rich:toggleControl for="#{containerName}:panel"
             value="next..."
             switchToState="x_#{texts.size() gt 3 ? texts[3].id : texts[0].id}"
             />
             </h:panelGroup>
             </f:facet>
             <f:facet name="x_#{texts[3].id}">
             <h:panelGroup>
             <h:outputText styleClass="#{textStle}" value="#{texts[3].digest}" />
             <rich:toggleControl for="#{containerName}:panel"
             value="next..."
             switchToState="x_#{texts.size() gt 4 ? texts[4].id : texts[0].id}"
             />
             </h:panelGroup>
             </f:facet>
             <f:facet name="x_#{texts[4].id}">
             <h:panelGroup>
             <h:outputText styleClass="#{textStle}" value="#{texts[4].digest}" />
             <rich:toggleControl for="#{containerName}:panel"
             value="next..."
             switchToState="x_#{texts[0].id}"
             />
             </h:panelGroup>
             </f:facet>
             </rich:togglePanel>
            
             </h:form>
            

            And, again, if I take out the stateOrder, nothing is rendered.

            • 3. Re: rich:togglePanel problems
              henrik.lindberg

              This is using a snapshot richfaces-3.0.2-20070726.000143-39

              and seam 2 beta

              • 4. Re: rich:togglePanel problems
                henrik.lindberg

                I just learned something - ui:repeat has a UI element in the tree, whereas c:forEach is just a tag.

                So, replacing ui:repeat with c:forEach makes a big difference. (Will post something that works). But I can't get around listing all the states...