简体   繁体   English

如何禁用 <h:commandButton> 在jsf中,而窗体加载?

[英]How To disable a <h:commandButton> in jsf while form gets loading?

I am developing a web form using jsf. 我正在使用jsf开发Web表单。 In that i need to disable the while the form gets loading,then again it wil enable after completing the form loading 因为我需要在加载表单时禁用,然后在完成表单加载后再次启用

Put a <script> right after the button which disables it. 在禁用该按钮的按钮之后放置<script>

<h:form id="myform">
    <h:commandButton id="mybutton" />
    <script>document.getElementById('myform:mybutton').disabled = true;</script>

On window.onload , enable it again. window.onload ,再次启用它。 It doesn't matter where this script is placed. 放置此脚本的位置无关紧要。

<script>window.onload = function() { document.getElementById('myform:mybutton').disabled = false; }</script>

That can be done only on the client side, with javascript: 只能使用javascript在客户端完成此操作:

  • disable it (set "enabled" to false) in a javascript snippet right after the button. 在按钮后的javascript代码段中将其禁用(将“启用”设置为false)。 Or in fact disabled it at the very start by setting disabled="true" 或者实际上在一开始就通过设置disabled="true"禁用它
  • onload (or at the end of the body) enable it. onload(或在主体末端)启用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM