【发布时间】:2012-02-10 02:37:29
【问题描述】:
我试图让 Primefaces MenuItem [在 Menubar 内] 发出 ActionEvent 并在按下时调用一个方法,但是,监听方法永远不会被调用,我不知道为什么:
xhtml 页面:
<h:body>
<h:form>
<p:menubar model="#{testBean.model}" />
<h:commandButton value="submit" />
<h:outputText value="#{testBean.confirmation}" />
</h:form>
</h:body>
</html>
jsf 豆:
@ManagedBean
public class TestBean implements ActionListener{
MenuModel model = new DefaultMenuModel();
private String confirmation = "negative";
public TestBean() {
MenuItem item = new MenuItem();
item.setValue("Click");
item.setUrl("#");
item.addActionListener(this);
model.addMenuItem(item);
}
@Override
public void processAction(ActionEvent event)
throws AbortProcessingException {
// EXECUTION NEVER REACHES HERE!
confirmation = "positive";
}
public MenuModel getModel() {
return model;
}
public String getConfirmation() {
return confirmation;
}
}
这可能有助于可视化非常简单的输出:
我正在使用 Primefaces 3.1.0 和 JSF 2.0
【问题讨论】:
-
这个问题处理的代码非常相似,但似乎更成功:stackoverflow.com/questions/5432897/…
标签: jsf jsf-2 primefaces actionlistener