我遇到了commandButton的问题,它只在提交类型时才有效.有人可以看看,如果有解决方案让我知道吗?下面的代码非常简单,并且有建议说明我需要的东西.方法test()未执行.方法runSubmit成功执行.
我需要在没有提交的情况下执行测试方法,因为原始页面确实具有在提交期间执行的验证,test()方法必须在没有提交的情况下执行,因为它是提交之前的初步操作.
我正在使用PrimeFaces 4.0,JDK 7,Tomcat 6和JSF 2.0(Apache),但我认为它也在Mojarra中发生.
SESSION:
package com.andre.bean;
public class AndreBean {
public void runSubmit() {
System.out.println("Submit executed");
}
public String test() {
System.out.println("Not submit executed");
return "true";
}
}
Run Code Online (Sandbox Code Playgroud)
XHTML
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:form id="test">
<p:commandButton id="ns" value="not submit" type="button" action="#{andreBean.test}" ajax="false"></p:commandButton>
<p:commandButton id="s" value="submit" action="#{andreBean.runSubmit}"></p:commandButton>
</h:form>
</html>
Run Code Online (Sandbox Code Playgroud)
非常感谢安德烈