【发布时间】:2013-12-05 13:49:57
【问题描述】:
这是我的情况:
我想测试是否无论如何链接java bean和xhtml,所以我使用richfaces,a4j:jsFunction来处理它。
我成功了——在某种程度上,事件启动器必须在表单之外触发,所以很奇怪!
我的代码有 3 个部分:xhtml、js、java
xhtml:
<button id="succeed" onclick="showMessage()"> succeed_test </button>
<!-- this is the succeeded button -->
<h:form id="form1" prependId="true" >
<button id="fail" onclick="showMessage()"> fail_test </button>
<!-- this is the failed button -->
<a4j:jsFunction
name="showMessage"
data="#{javaBeanTest.showThings()}"
oncomplete="presentData(data)"
immediate="true" />
</h:form>
js:
function presentData(data){
alert(data);
}
java:
@Name("javaBeanTest")
public class JavaBeanTest implements Serializable{
public boolean showThings(){
System.out.println("--JavaBeanTest.showThings()");
return true;
}
}
当点击「succeed_test」按钮时,我在控制台上得到一个「true」警告和「--JavaBeanTest.showThings()」,但在控制台上只有「undefined」警告和「--JavaBeanTest.showThings()」同时点击「fail_test」按钮。
显然差异是在形式内部或外部.....
困惑!!!!请!!!
ps.在我的 Richfaces 版本中,它适用于「data」而不是「event.data」,应该是 3.x
JDK 1.6
JBDS 4.1.0GA
接缝 2.2
JSF 1.2
【问题讨论】:
标签: javascript jsf richfaces