我的代码:
<h:form id="newBSTypePanel" >
<h:panelGrid columns="2" id="newRecod" >
<h:outputText value="Name"/><h:inputText value="#{treeTableController.newBStypeBean.currentObject.TYPENAME.value}" required="true" />
<p:commandButton value="save" action="#{treeTableController.saveNewNodes}" oncomplete="Dlg.hide()" update="productDataForm"/>
<p:commandButton value="close" oncomplete="Dlg.hide()" />
</h:panelGrid>
</h:form>
Run Code Online (Sandbox Code Playgroud)
保存操作有很多相关的功能.如果我反复单击该按钮,它可能会在数据库中保存一些记录.那不是我的愿望.如何防止多次点击并解决此问题?
Fis*_*Gel 36
在<p:commandButton>的客户端API的Widget:
PrimeFaces.widget.CommandButton
方法参数返回类型描述
disable() - void禁用按钮enable() - void启用按钮所以你可以像这样使用:
<p:commandButton widgetVar="saveButton"
onclick="saveButton.disable()"
value="save"
action="#{treeTableController.saveNewNodes}"
oncomplete="saveButton.enable();Dlg.hide()"
update="productDataForm"/>
Run Code Online (Sandbox Code Playgroud)
对于较新版本的PrimeFaces,解决方案是:
<p:commandButton widgetVar="saveButton"
onclick="PF('saveButton').disable()"
value="save"
action="#{treeTableController.saveNewNodes}"
oncomplete="PF('saveButton').enable();PF('Dlg').hide()"
update="productDataForm"/>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17448 次 |
| 最近记录: |