【发布时间】:2012-08-13 07:44:52
【问题描述】:
我使用数据表来显示一些记录。用户可以使用名为 actionsDialog 的对话框添加/更改记录。在保存记录之前,会显示一个名为 reasonDialog 的模式对话框,用户必须为当前操作输入一些原因。在我的逻辑中,我将数据保存到数据库后将原因设置为空。
重复操作时出现问题。原因包含先前的值。我已经调试了代码并注意到发生这种情况是因为原因被分配了 inputTextarea 的本地值。我怎样才能摆脱本地价值?我正在使用 PrimeFaces 3.0、Mojara 2.0.4、Tomcat 7。
我的原因对话框 facelet 是:
<ui:composition 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.prime.com.tr/ui">
<p:dialog header="#{label.reason}" widgetVar="reasonDialog"
showEffect="fade" hideEffect="explode" modal="true" dynamic="true">
<h:panelGrid columns="2">
<p:inputTextarea rows="5" cols="40" autoResize="false"
value="#{recordsBean.reason}" maxLength="1024" />
<f:facet name="footer">
<p:outputPanel layout="block">
<p:commandButton value="ok" update="genericRecords msgs"
action="#{recordsBean.execute}"
oncomplete="reasonDialog.hide();actionsDialog.hide()" />
</p:outputPanel>
</f:facet>
</h:panelGrid>
</p:dialog>
</ui:composition>
操作对话框如下所示:
<p:dialog id="actionsDialog" widgetVar="actionsDialog" dynamic="true"
resizable="false" height="600" showEffect="fade" hideEffect="fade" modal="true">
<ui:include src="/WEB-INF/flows/genericRecord.xhtml"/>
<f:facet name="footer">
<p:outputPanel layout="block">
<p:commandButton value="save" onclick="reasonDialog.show()" />
<p:commandButton value="cancel" immediate="true"
oncomplete="actionsDialog.hide()" />
</p:outputPanel>
</f:facet>
</p:dialog>
【问题讨论】:
-
尝试为您的对话框分配一个 ID
id="reasonDialogID"并在打开对话框的按钮的update属性中添加其 ID -
我已将 id="reasonDialogId" 添加到对话框并将其设置为按钮的更新属性,但它仍然无法正常工作。除此之外,原因值设置不正确,始终为空。
-
你没有在那个按钮点击中调用一些bean方法吗?一种将数据设置为
recordsBean的方法?recordsBean的范围是什么,至少使其成为视图范围... -
当按钮被点击时,recordsBean 的执行方法被调用。 recordsBean 是会话范围的。
-
确保在该按钮单击完成时打开
reasonDialog对话框?发布打开对话框的那个按钮的代码......
标签: java jsf dialog primefaces