关闭Dialog时为什么调用setDataTransferRangeInSeconds()方法?通常我在关闭Dialog时可能没有被调用?
<h:form>
<p:dialog header="Service Alarm Options"
widgetVar="updatedlg"
closable="true"
minWidth="500"
minHeight="1000"
resizable="false"
dynamic="false"
>
<h:panelGrid id="servicedetails">
<p:commandButton value="Save"
action="#{alarmBean.updateServiceOptions}" />
<p:commandButton value="#{messages.exit}" icon="ui-icon-close"
style="valign:bottom;float:right;padding-right:20px"
oncomplete="updatedlg.hide();">
</p:commandButton>
<p:inputText
value="#{alarmBean.selectedDocument.dataTransferRangeInSeconds}"></p:inputText>
</h:panelGrid>
</p:dialog>
</h:form>
更新。
<p:dialog header="Service Alarm Options" widgetVar="updatedlg"
closable="true" minWidth="500" minHeight="1000" resizable="false"
dynamic="false">
<h:form>
<h:panelGrid id="servicedetails">
<p:commandButton value="Save"
action="#{alarmBean.selectedDocument.saveNewFeatures}" />
<p:commandButton value="#{messages.exit}" icon="ui-icon-close"
style="valign:bottom;float:right;padding-right:20px"
onclick="updatedlg.hide();" type="button" />
<p:inputText
value="#{alarmBean.selectedDocument.dataTransferRangeInSeconds}"></p:inputText>
</h:panelGrid>
</h:form>
</p:dialog>
答案 0 :(得分:0)
通常不会,但将对话框放在表单中是不正确的。重新排序代码并将表单放在对话框中:
<p:dialog>
<h:form>
<!-- your form -->
</h:form>
</p:dialog>
此外,退出按钮是AJAX按钮(Primefaces中的默认按钮),它发送AJAX请求,并在该请求之后隐藏对话框。在该请求期间,来自输入的值将在bean中发送和设置。将按钮更改为:
<p:commandButton value="#{messages.exit}" icon="ui-icon-close"
style="valign:bottom;float:right;padding-right:20px"
onclick="updatedlg.hide();" type="button"/>
这将创建按钮,只需调用javascript即可关闭对话框。
答案 1 :(得分:0)
<p:dialog header="Service Alarm Options" widgetVar="updatedlg"
closable="false" minWidth="500" minHeight="1000" resizable="false"
dynamic="false">
<h:form>
<h:panelGrid id="servicedetails">
<p:commandButton value="Save"
action="#{alarmBean.selectedDocument.saveNewFeatures}" />
<p:commandButton value="#{messages.exit}" icon="ui-icon-close"
style="valign:bottom;float:right;padding-right:20px"
update="@form"
actionListener="#{alarmBean.selectedDocument.resetFeatures}"
oncomplete="updatedlg.hide();">
</p:commandButton>
<p:inputText
value="#{alarmBean.selectedDocument.dataTransferRangeInSeconds}"></p:inputText>
</h:panelGrid>
</h:form>
</p:dialog>