p:commandbutton不工作或不叫
我是新手在jsf网络应用程序, 我创建一个jsf页面与一个命令按钮, 但它不会工作我不知道为什么? 我给actionlistener,行动后,但它不会工作, 所以请帮助我?p:commandbutton不工作或不叫
HTML代码
<p:panelGrid columns="2" id="display" columnClasses="label,value">
<h:outputText value="Mobile Number" />
<p:inputMask id="phoneWithExt" value="#{GenerateOtp.EVD}" mask="(999) 999-9999" maxlength="10"/>
<h:outputText value="Mpin" />
<p:inputMask id="mpin" value="#{GenerateOtp.MPin}" mask="9-9-9-9" maxlength="4"/>
<h:outputText value="Imei Number" />
<p:inputText id="imei" alt="Imei Number" value="#{GenerateOtp.IMEI}"/>
<h:outputText value="User Agent" />
<p:inputText id="useragent" alt="User Agent" value="#{GenerateOtp.useragent}"/>
</p:panelGrid>
<p:commandButton id="call" type="button" value="Call"
actionListener="#{GenerateOtp.buttonAction(actionEvent)}"
process="@this"
icon="ui-icon-check" />
管理的bean:
@ManagedBean(name = "GenerateOtp")
@ViewScoped
public class GenerateOtp extends MasterRequest {
@SerializedName("EVD")
@Expose
private String eVD;
@SerializedName("mPin")
@Expose
private String mPin;
public String getEVD() {
return eVD;
}
public void setEVD(String eVD) {
this.eVD = eVD;
}
public String getMPin() {
return mPin;
}
public void setMPin(String mPin) {
this.mPin = mPin;
}
public void callOtp() {
System.out.println("evd" + getEVD());
}
public void buttonAction(ActionEvent actionEvent) {
addMessage("evd" + getEVD());
}
public void addMessage(String summary) {
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, summary, null);
FacesContext.getCurrentInstance().addMessage(null, message);
}
}
的ActionListener的没有一个类型= “按钮” 的commandButton工作。所以你需要删除type =“button”。
您需要的类型是“提交”,但是因为它是默认类型,所以不需要声明它。
<p:commandButton id="call" value="Call"
actionListener="# GenerateOtp.buttonAction(actionEvent)}"
process="@this" icon="ui-icon-check" />
如果更改像这样的按钮将工作,如果你的代码的其余部分是正确的(EQ作为BrunoDM说你需要一个形式,如果你没有一个按钮仍然无法工作)
这些信息全部都在我提到的副本中。所以请标记为这样。这可以防止*中的碎片和大量类似的Q/A。我知道这个(不幸的是)不会给你'repuation'点,但它是在*中的'很好的做法'。谢谢 – Kukeltje
对不起,没有看到你的重复线程。我刚刚看到了错误,并希望提供帮助。我现在标记了这个问题。说实话,我不在乎名誉,我只是想帮助人们:) – lastresort
酷炫的感谢,带着这么多体育精神。对我来说也是如此。干杯!但你应该选择'关闭'按钮然后'重复'。只是'提高'我的(自动生成的)评论是不够的。 – Kukeltje
你的表格在哪里? – BrunoDM
[commandButton/commandLink/ajax动作/侦听器方法未被调用或输入值未更新]的可能重复(https://*.com/questions/2118656/commandbutton-commandlink-ajax-action-listener-method-not-invoked - 或 - 输入值) – Kukeltje