我有一个Dialog输入详细信息.第一次,InputText为空.但是从第二个输入,InputText保持以前的值.
这是我的代码:
<p:commandButton id="showDialogButton1" type="button" value="add" onclick="dlg1.show()" update="firstname1"/>
<p:dialog id="dialogAjout" header="add department" widgetVar="dlg1" resizable="false">
<h:panelGrid columns="2" style="margin-bottom:10px">
<h:outputLabel for="firstname1" value="Libellé :" />
<p:inputText id="firstname1" value="#{departementBean.departement.libelleDepartement}" />
</h:panelGrid>
<p:commandButton id="submitButton1" value="Valider" oncomplete="dlg1.hide();" action="#{departementBean.addDept()}" update="tabView"/>
</p:dialog>
Run Code Online (Sandbox Code Playgroud)
请问我怎么解决这个问题!
小智 7
您可以使用此primefaces组件:http:
//www.primefaces.org/showcase/ui/misc/resetInput.xhtml
关于一般的对话框:不要将它们放在表单中.请改为:<p:dialog><h:form>...
关于update =""值,如果你的appendToBody为true,则在id前面放一个冒号(这意味着它是另一种形式).
小智 5
添加resetValues="true"到您的命令按钮
<p:commandButton resetValues="true" action="#{departementBean.prepareDialog}" id="showDialogButton1" type="button" value="add" oncomplete="dlg1.show()" update=":dialogAjout"/>
Run Code Online (Sandbox Code Playgroud)
小智 5
您应该使用以下代码:
<h:commandButton value="Reset" style="margin-right:20px;">
<p:ajax update="registrationForm" resetValues="true" />
</h:commandButton>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
28166 次 |
| 最近记录: |