1

我在一个 xhtml 页面中当然有一个 bean 绑定的消息。

现在消息在一个列表中,我正在使用 ui:repeat 来显示消息和所有内容。现在,当我打开一条消息时,dialogGrid 中有一个回复按钮,它会在同一页面上打开另一个对话框,我只需要将数据传递给该回复对话框。首先,它工作正常,我的意思是,如果您直接单击回复按钮,它工作正常,但是当您打开消息然后单击回复时,它不会更新对话框。

在同一页面中看到了这个 Pass 参数到对话框

但是我的 Bean 是请求范围的

这是我的 xhtml 代码

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui" 
      xmlns:c="http://java.sun.com/jsp/jstl/core">
    <h:head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link rel="stylesheet" type="text/css" href="../Styles/homepage-style.css" />
        <link rel="stylesheet" type="text/css" href="../Styles/profile.css" />
        <title>Shadi Bandhan | We find the best match for you</title>
    </h:head>

    <h:body>

        <div id="header">
            <ui:insert name="header" >
                <ui:include src="header.xhtml" />
            </ui:insert>
        </div>

        <div id="main-content">
            <p:growl autoUpdate="true" />

            <div id="left-pane">

                <div id="profile-info-area">
                    <ui:insert name="profile_info_area" >
                        <ui:include src="profileInfoArea.xhtml" />
                    </ui:insert>
                </div>

                <div id="home-main-area">
                    <div id="messages-wrapper">

                        <div id="messages-header">

                            <div id="m-heading">
                                Messages - Inbox
                            </div>

                            <div id="m-search">

                                <div id="searchbox">
                                    Search Messages <input type="text" value="Search" />
                                </div>

                                <div id="newmessage">
                                    <a href="#"> + New Message </a>
                                </div>

                            </div>

                        </div>

                        <h:form id="messagesForm">
                            <div id="messages">

                                <p:dialog id="messagesDialog" modal="true" widgetVar="messageDialog" resizable="false"  width="750" height="300" header="New Message" >  

                                    <h:panelGrid columns="2" id="dialogGrid">
                                        <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 maxlength="300"  id="msgContents" value="#{messagesManagedBean.msg.message}" cols="65" rows="3" >
                                                <p:watermark for="msgContents" value="#{userMsg.userId}" />
                                            </p:inputTextarea>


                                        </p:column>

                                        <p:column>
                                            <p:commandButton id="msgSend" value="Send" action="#{messagesManagedBean.sendMessage('reply')}" oncomplete="messageDialog.hide()"  >
                                                <f:param value="#{userMsg.userId}" name="messageSenderId" />
                                            </p:commandButton> 
                                        </p:column>

                                    </h:panelGrid>

                                </p:dialog>

                                <p:dialog id="messagesDialog2" modal="true" widgetVar="messageDialog2" resizable="false"  width="750" height="300" header="New Message" >  

                                    <h:panelGrid columns="2" id="dialogGrid2">
                                        <p:column>
                                            <h:outputLabel for="msgRecepient2"  value="From"/>
                                        </p:column>
                                        <p:column>
                                            <h:outputLabel id="msgRecepient2" value="#{userMsg.userFullname}"  >

                                            </h:outputLabel>
                                        </p:column>
                                        <p:column>
                                            <h:outputLabel for="msgContents2"  value="Message"/>
                                        </p:column>
                                        <p:column>
                                            <p:inputTextarea readonly="true" id="msgContents2" value="#{userMsg.message}" cols="65" rows="3" >

                                            </p:inputTextarea>
                                        </p:column>
                                        <p:column>
                                            <p:commandButton styleClass="reply-btn" value="Reply" update=":messagesForm:dialogGrid"
                                                             oncomplete="messageDialog.show(), messageDialog2.hide()">
                                                <f:param name="userMsg" value="#{userMsg}" />
                                            </p:commandButton>
                                        </p:column>

                                    </h:panelGrid>

                                </p:dialog>

                                <ui:repeat var="userMsg" value="#{messagesManagedBean.paginator1.model}">

                                    <center><img class="h-diff" src="../images/differentiator-profile.jpg" width="437" height="1" /></center>

                                    <div id="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>
                                            <ui:fragment rendered="#{userMsg.isRead}">
                                                <div id="message-txt">
                                                    #{userMsg.message}
                                                </div>
                                            </ui:fragment>
                                            <ui:fragment rendered="#{not userMsg.isRead}">
                                                <div id="message-txt" class="msgNotRead">
                                                    #{userMsg.message}
                                                </div>
                                            </ui:fragment>
                                            <div id="msgAction">

                                                <p:commandLink styleClass="reply-btn"
                                                               value="Reply" oncomplete="messageDialog.show()" update=":messagesForm:dialogGrid">
                                                    <f:param name="userMsg" value="#{userMsg}" />
                                                </p:commandLink>

                                                <ui:fragment rendered="#{userMsg.isRead}">
                                                    <p:commandLink styleClass="open-btn" value="Open" 
                                                                   oncomplete="messageDialog2.show()" update=":messagesForm:dialogGrid2">
                                                        <f:param name="userMsg" value="#{userMsg}" />
                                                    </p:commandLink>
                                                </ui:fragment>

                                                <ui:fragment rendered="#{not userMsg.isRead}">
                                                    <p:commandLink styleClass="open-btn" value="Open" 
                                                                   action="#{messagesManagedBean.messageOpenedListener(userMsg.messageId)}" 
                                                                   oncomplete="messageDialog2.show()" update=":messagesForm:dialogGrid2">
                                                        <f:param name="userMsg" value="#{userMsg}" />
                                                    </p:commandLink>
                                                </ui:fragment>
                                            </div>

                                        </div>
                                    </div>

                                </ui:repeat>
                                <h:commandButton value="&lt; prev" action="#{messagesManagedBean.paginator1.prev}"/>
                                <h:outputText value="#{messagesManagedBean.paginator1.pageIndex} / #{messagesManagedBean.paginator1.pages}"/>
                                <h:commandButton value="next &gt;" action="#{messagesManagedBean.paginator1.next}"/>
                                <h:inputHidden value="#{messagesManagedBean.paginator1.pageIndex}"/>

                            </div>
                        </h:form>



                    </div>
                </div>
            </div>

            <div id="right-pane">
                <ui:insert name="right-pane" >
                    <ui:include src="right-pane.xhtml" />
                </ui:insert>
            </div>
        </div>

        <div id="footer">
            <ui:insert name="footer" >
                <ui:include src="footer.xhtml" />
            </ui:insert>
        </div>

    </h:body>
</html>
4

0 回答 0