3 Replies Latest reply on Mar 2, 2010 5:29 AM by Ilya Shaikovsky

    A modalPanel ID question.

    Christophe Vermeylen Newbie

      Hello, i'm a student on the university of Antwerp and I have to make a project using JSF.

       

      So to make it more interactive I decided to use RichFaces. Now my question is more a question on how i should program it.

       

      The thing is, I'm making a message controller.

      So i use a <c:forEach> and in this <c:forEach> i'm printing a text like 'You have a new message from Obama'.

      The 'message' contains a link to the modalPanel where the message will be displayed.

      Everything works if i only have 1 message in my inbox. The problem occure when i have multiple messages.

      Because i'm placing my modalPanel in my <c:forEach> I have multiple modalPanels with the same ID. Which causes problems ofcourse!

       

      Now I was thinking, would it be possible to set the modalPanel out of the <c:forEach> and use some kind of parameter to set that message in the modalPanel.

      Or would it be possible to automaticly set an unique ID. (I already tried EL expression but that is not allowed in the ID).

       

      Would it be possible to give me an direction of how i should program this? Or if you have other solution please share :-)

       

      Thanks

      Christophe

       

      Here is my JSF code:

       

      <c:forEach items="#{logOnBean.messagesForUserNotRead}" var="message" varStatus="index">

          <rich:modalPanel id="panel" width="450" height="300" autosized="true">

              <f:facet name="header">

                  <h:panelGroup>

                      <h:outputText value="#{msgs.logon_messageFrom } #{message.sender.profile.name}"/>

                  </h:panelGroup>

              </f:facet>

              <f:facet name="controls">

                  <h:panelGroup>

                      <h:outputText value="#{msgs.logon_panelClose}" id="hidelink"/>

                      <rich:componentControl for="panel" attachTo="hidelink" operation="hide"

                                             event="onclick"/>

                  </h:panelGroup>

              </f:facet>

              <h:outputText value="#{message.message}"/>

       

              <h:outputLink value="#" id="answerLink">

                  <h:outputText value="#{msgs.logon_answerMessage}"/>

                  <rich:componentControl for="answerPanel" attachTo="answerLink"

                                         operation="show"

                                         event="onclick"/>

              </h:outputLink>

          </rich:modalPanel>

          <p>

              <h:outputText value="#{msgs.logon_messageFrom1} "/>

              <h:outputLink value="#" id="link">

                  <h:outputText value="#{msgs.logon_message} "/>

                  <rich:componentControl for="panel" attachTo="link" operation="show"

                                         event="onclick"/>

              </h:outputLink>

              <h:outputText value="#{msgs.logon_messageFrom2} "/>

              <h:outputText value="#{message.sender.profile.name}"/>

          </p>

      </c:forEach>