I'm showing messages from a list in my backing bean in xhtml jsf page.
I'm using ui:repeat for the loop and a reply button for each message. on the reply button, i'm calling a dialog box in which i'm showing the username displayed at the xhtml page. But it always show the name of the last message sender in the list.
Take a look at my xhtml code
<h:form>
<div id="messages">
<ui:repeat var="userMsg" value="#{messagesManagedBean.userInboxMsgs}">
<p:dialog modal="true" widgetVar="messageDialog" resizable="false" width="750" height="200" header="New Message" >
<h:panelGrid columns="2">
<p:column>
<h:outputLabel for="msgRecepient" value="To"/>
</p:column>
<p:column>
<h:outputLabel id="msgRecepient" value="#{userMsg.userFullname}" >
</h:outputLabel>
</p:column>
<p:column>
<h:outputLabel for="msgContents" value="Message"/>
</p:column>
<p:column>
<p:inputTextarea id="msgContents" value="#{messagesManagedBean.msg.message}" cols="65" rows="3" />
</p:column>
<p:column>
<p:commandButton id="msgSend" value="Send" action="#{messagesManagedBean.sendMessage(userMsg.userId,'reply')}" oncomplete="messageDialog.hide()" />
</p:column>
</h:panelGrid>
</p:dialog>
<center><img class="h-diff" src="../images/differentiator-profile.jpg" width="437" height="1" /></center>
<div class="message">
<div id="senderImg">
<img class="senderImg" src="../images/profile-pic.jpg" width="50" height="50" />
</div>
<div id="message-txt-area">
<div id="senderName">
<p:commandLink styleClass="senderName" value="#{userMsg.userFullname}" action="#{myProfileManagedBean.loadProfileFrontInformation(userMsg.userId)}"></p:commandLink>
</div>
<div class="message-txt">
#{userMsg.message}
</div>
<div class="reply-btn">
<a href="#" onclick="messageDialog.show()">Reply</a>
</div>
</div>
</div>
</ui:repeat>
</div>
</h:form>
Now the problem is when i click on reply it shows the dialog box but the "To" section contains the sendername of the last message in the list.
Thanks