【发布时间】:2012-06-10 12:04:19
【问题描述】:
我在 JSF + PrimeFaces 中构建了 Web 应用程序。在 web 表单中,我将 primefaces 的命令按钮的禁用属性设置为 true。 在对表单输入字段执行自定义客户端验证后加载表单时,我根据表单上的用户输入将命令按钮的禁用属性设置为 false 或 true。 注意:这里如果所有验证通过按钮被启用,但同时如果用户编辑某些输入并且验证失败,那么按钮再次被禁用。
<p:commandButton id="saveButton" value="Save" actionListener="#{some method of bean}"
update="component to update" disabled="true" />
但是按钮不能正常工作,我的意思是表单没有被提交。
但是如果按钮的 disabled 属性在开始时没有设置为 true,即使在自定义验证期间它被 javascript 禁用/启用(如上所述)它也可以正常工作。
我无法理解这个表单提交离子如何依赖于命令按钮的禁用属性的初始值,即使我是通过 javascript 设置它。
这是浏览器源代码中显示的 HTML 代码:
如果属性 disabled 设置为 true:
<button id="saveButton"
class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"
type="submit"
onclick="PrimeFaces.ab({formId:'createAccessPrivilegeForm',source:'saveButton',process:'@all',update:'centerPanel leftNavigationForm:leftNavigationTabView'});return false;"
name="saveButton"
role="button"
aria-disabled="false">
如果 disabled 属性设置为 false:
<button id="saveButton"
class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only ui-state-disabled"
disabled="disabled"
type="submit"
onclick="PrimeFaces.ab({formId:'createRoleForm',source:'saveButton',process:'@all',update:'centerPanel leftNavigationForm:leftNavigationTabView'});return false;"
name="saveButton"
role="button"
aria-disabled="true">
帮助我处理这种情况。我希望命令按钮最初只被禁用,它只有在验证通过后才会被禁用,我希望它能够提交表单。
【问题讨论】:
标签: javascript jsf jsf-2 primefaces