按照描述Here
点击后,我将禁用该按钮这是我的代码,但点击后无法禁用该按钮。
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
<title></title>
<script language="JavaScript" type="javascript">
function handleDisableButton(data) {
if (data.source.type != "submit") {
return;
}
switch (data.status) {
case "begin":
data.source.disabled = true;
break;
case "complete":
data.source.disabled = false;
break;
}
}
jsf.ajax.addOnEvent(handleDisableButton);
</script>
</h:head>
<h:body>
<h:form>
<h:inputText id="email" value="#{bean2.email}"/>
<h:commandButton id="saveBtn" action="#{bean2.showClicked}" value="send">
<f:ajax onevent="handleDisableButton"/>
</h:commandButton>
</h:form>
</h:body>
</html>
而showClicked()
只是说clicked
:
@ManagedBean
@SessionScoped
public class Bean2 {
private String email;
public void showClicked(){
System.out.println("clicked");
}
//getter/setter for email
}
代码正是他的首选。