【发布时间】:2014-02-20 16:40:27
【问题描述】:
简单的问题......在commandLink 的action 属性中,我可以调用viewController 提供的对象的方法吗?我无法使以下设置正常工作,而且我不知道问题出在哪里 - 我没有收到错误,只是没有发生任何事情。
测试对象
public class TestObject {
public void testMethod() {
System.out.println("This is a test method");
}
}
视图控制器
@ManagedBean
@ViewScoped
public class ViewController {
private TestObject testObject = new TestObject();
public TestObject getTestObject() {
return testObject;
}
public void testMethod() {
testObject.testMethod();
}
}
JSF
<!-- This does not work -->
<h:commandLink action="#{viewController.testObject.testMethod}" value="On internal Object"/>
<!-- This works -->
<h:commandLink action="#{viewController.testMethod}" value="On ViewController"/>
编辑:抱歉,忘了提及:我尝试拨打 testMethod() 和 viewController.getTestObject().testMethod() 均无济于事。
【问题讨论】:
标签: jsf managed-bean