无法从复合 JSF 组件引用 Bean 中的方法



i具有以下复合组件testcc.xhtml:

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:cc="http://java.sun.com/jsf/composite">
<cc:interface>
<cc:attribute name="manager" method-signature="java.lang.String helloTest()" required="true"/>
</cc:interface>
<cc:implementation>
Hello #{cc.attrs.manager} !!!!!!!!!!!!!!!!!!!!!
</cc:implementation>
</html>

当我尝试在JSFF文件中调用它时:

....
<icc:TestCC manager="#{viewScope.PatientClinicalBean.helloTest}"/>
...

页面在我的复合标签上崩溃,并在控制台中使用以下消息:

javax.el.ELException: //C:/Documents and Settings/tlam/Application Data/JDeveloper/system11.1.2.3.39.62.76.1/o.j2ee/drs/iCHIP/ViewControllerWebApp.war/WEB-INF/classes/META-INF/resources/IchipComponent/TestCC.xhtml: javax.el.PropertyNotFoundException: //C:/Documents and Settings/tlam/Application Data/JDeveloper/system11.1.2.3.39.62.76.1/o.j2ee/drs/iCHIP/ViewControllerWebApp.war/Patient/Profile/Clinical.jsff @13,86 manager="#{viewScope.PatientClinicalBean.helloTest}": The class 'patient.profile.PatientClinicalBean' does not have the property 'helloTest'.

但是我的托管bean确实有一个公共字符串hellotest()方法,以及其他在我的JSFF页面其他位置正常工作的方法:

public class PatientClinicalBean{
String test = "TESTING"; 
...
public String helloTest() {
  return test;
}
...
}

我尝试了多次使用不同的方法,所有次都具有相同的结果。但是,如果我的复合组件仅输出一个字符串,然后输入表达式以直接访问字符串测试字段,则它将正确执行。当其他方法调用在同一JSFF页面中正常工作时,我似乎无法仅从我的复合组件中引用患者熟食中的任何方法。我在网络上看到的所有其他示例都没有问题,就像我缺少某些东西一样吗?!

在JSF2上,如果您在调用方法,则需要添加括号,例如:

....
<icc:TestCC manager="#{viewScope.PatientClinicalBean.helloTest()}"/>
...

否则JSF将其解释为一个字段,并尝试找到Gethellotest()。

最新更新