我的应用程序中有一个奇怪的行为,我没有解决它的选项,因为有时它可以工作,而有时它不能(取决于组件层次结构)。基本上,我正在使用 inputTextArea 并通过 setPropertyActionListener 将值发送到我的服务器,以便在我的应用程序上进行进一步的逻辑。该功能实际上是一个评论列表。
<h:panelGroup rendered="#{(cc.attrs.requestCommentListComponentModel.requestCommentEditableMap[requestCommentVar.id]) and (cc.attrs.isModificationAllowed)}">
<div>
<p:inputTextarea id="modifyRequestCommentInputTextArea" maxlength="255" styleClass="modifyRequestCommentInputTextArea" value="#{requestCommentVar.comment}" />
</div>
<h:panelGroup id="modifyRequestCommentControlButtonsPanelGroup" styleClass="requestCommentControlButtonsPanelGroup">
<p:commandButton
id="cancelRequestCommentModificationCommandButton"
action="requestCommentListComponent.cancelEditRequestComment"
onclick="jQuery.simpleBlockUI();cleanWatermark();"
onerror="jQuery.unblockUI();"
oncomplete="showWatermark();jQuery.unblockUI();closeComponent('#entityTaskManagementDialog');closeComponent('#quickTaskDialog');"
process="@none"
styleClass="requestCommentListComponentCommandButton"
value="#{omnimed['global.cancel']}">
<f:setPropertyActionListener target="#{cc.attrs.requestCommentListComponentModel.currentRequestComment}" value="#{requestCommentVar}" />
<f:setPropertyActionListener target="#{conversationScope.requestCommentListComponentModel}" value="#{cc.attrs.requestCommentListComponentModel}" />
</p:commandButton>
<p:commandButton
id="saveRequestCommentModificationCommandButton"
action="requestCommentListComponent.updateRequestComment"
onclick="jQuery.simpleBlockUI();cleanWatermark();"
onerror="jQuery.unblockUI();"
oncomplete="showWatermark();jQuery.unblockUI();closeComponent('#entityTaskManagementDialog');closeComponent('#quickTaskDialog');"
styleClass="postButton requestCommentListComponentCommandButton"
value="#{omnimed['global.save']}">
<f:setPropertyActionListener target="#{cc.attrs.requestCommentListComponentModel.currentRequestComment}" value="#{requestCommentVar}" />
<f:setPropertyActionListener target="#{conversationScope.requestCommentListComponentModel}" value="#{cc.attrs.requestCommentListComponentModel}" />
</p:commandButton>
</h:panelGroup>
</h:panelGroup>
所以,问题是当我使用 setPropertyActionListener 获得值(#{requestCommentVar.comment})时。有一个值,但它始终是旧的(也就是存储在模型中的那个)。如果我输入一个新文本,它仍然会让我回到旧值而没有错误。我以前做过这个实现并且它有效。
另外,我应该说我在另一个组件中有一个组件。所以,我有一个 A 类的数据表(ui-repeat),每个在我的父级组件中还包含一个 B 类的数据表(ui-repeat)。然后我有一个子组件,它对于每个 A 类都有我的 C 类的数据表(ui-repeat)。C 类实际上是一个评论列表,当我尝试修改评论时遇到问题。