Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Forms 重置JSF表单字段_Forms_Jsf - Fatal编程技术网

Forms 重置JSF表单字段

Forms 重置JSF表单字段,forms,jsf,Forms,Jsf,我知道围绕这个主题已经做了很多,但是所有的解决方案都指出要创建一个重置按钮。。。难道没有办法清理这些字段并重新填充它们吗 这是我的代码 <p:commandButton id="basic" value="#{c.machine}" action="#{updateEntry.setMachine(c.machine)}" oncomplete="dlg1.show();" styleClass="ui-Machinebutton"/> 这将在“updateEntry”中设置值

我知道围绕这个主题已经做了很多,但是所有的解决方案都指出要创建一个重置按钮。。。难道没有办法清理这些字段并重新填充它们吗

这是我的代码

<p:commandButton id="basic" value="#{c.machine}" action="#{updateEntry.setMachine(c.machine)}" oncomplete="dlg1.show();" styleClass="ui-Machinebutton"/>

这将在“updateEntry”中设置值“machine”,完成后启动对话框“dlg1”

对话框

<p:dialog id="Update_Entry" header="Update Entry" widgetVar="dlg1" modal="true" height="250" dynamic="True" resizable="False">  
                    <h:form prependId="false" id="Update_Entry_Form" method="post" autocomplete="off">  

                            <h:panelGrid id="update_grid" columns="2" style="margin-bottom:10px"> 

                                <f:facet name="header">  
                                    <p:messages />  
                                </f:facet> 
                                <h:outputLabel for="machine" value="Machine *" />  
                                <p:inputText id="machine" value="#{updateEntry.machine}" required="true" requiredMessage="Machine is required">
                                    <f:validateLength minimum="5" maximum="5"/>
                                </p:inputText>


表单第一次加载值fine,但即使updateEntry.machine被更新,它也始终加载上一个值。如何自动清除此项?我使用的是PrimeFaces

您在打开对话框之前忘记了ajax更新对话框内容。这就是为什么它总是像第一次呈现页面或最后一次关闭对话框时那样显示初始内容的原因

相应地这样做:

<p:commandButton ... update=":Update_Entry">

您忘记在打开对话框之前更新对话框内容。这就是为什么它总是像第一次呈现页面或最后一次关闭对话框时那样显示初始内容的原因

相应地这样做:

<p:commandButton ... update=":Update_Entry">


清除托管bean中的值。更新对话框后,更新操作上的对话框dom树,update=“:update\u grid”,如果您不想让他们看到更新的值,您可以始终更改bean的作用域以请求作用域清除托管bean中的值。更新对话框后,更新操作上的对话dom树,update=“:update_grid”,如果您不想让他们看到更新的值,您可以随时将bean的范围更改为requestScopeThank!这是可行的,尽管ajax更新需要在“对不起”中完成,但在输入答案时我没有动脑筋。修好了,谢谢!这是可行的,尽管ajax更新需要在“对不起”中完成,但在输入答案时我没有动脑筋。修好了。