如何禁用提交按钮,直到按下其他按钮?
我有一个简单的 JSF 表单:
<h:form>
<h:inputText value="#{textBean.firstName}"/>
<h:inputText value="#{textBean.lastName}"/>
<h:commandButton value="confirm" action="textBean.confirm"/>
<h:commandButton value="submit" action="textBean.submit"/>
</h:form>
在单击“提交”之前,用户必须按“确认”按钮。否则,“提交”按钮旁边会显示错误消息。如果没有预先按下确认,用户无法单击提交按钮。在UI的一层上做是非常可取的。有些人可能会对此提出一些建议?
I have a simple JSF form:
<h:form>
<h:inputText value="#{textBean.firstName}"/>
<h:inputText value="#{textBean.lastName}"/>
<h:commandButton value="confirm" action="textBean.confirm"/>
<h:commandButton value="submit" action="textBean.submit"/>
</h:form>
It is necessary that before you click "submit" user must press the button "confirm". Otherwise, next to the button "submit" display an error message. A user can not click the submit button, if not pre-pressed to confirm. It is very desirable to do it on a layer of the UI. Some might suggest something about this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能想要更改逻辑,以便在单击提交按钮时向用户显示确认对话框。像这样简单的事情:
否则,如果您想获得上述行为,您可以禁用/隐藏提交按钮,直到用户单击确认按钮,例如:
如果您想隐藏,可以将禁用属性替换为渲染属性按钮。它需要一个布尔值。可以在确认方法中将此布尔变量设置为 true,以便在请求返回时启用该按钮。
You might want to change the logic so that on click of the submit button a confirmation dialog box is presented to the user. Something simple like this:
Otherwise if you want to get the behaviour mentioned above you could disable / hide the submit button until the user has clicked the confirm button, something like:
The disabled attribute can be replaced with the rendered attribute if you want to hide the button. It takes a boolean. This boolean variable can be set in your confirm method to true so that when the request comes back the button will be enabled.