当单击特定的 commandMenuItem 时,我想在标签中显示不同的菜单页面片段默认页面片段正在正确显示,但是在菜单单击时页面没有刷新,通过 actionListner 获取页面 id 但仍然没有刷新我的代码同样是:-
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<f:view xmlns:f="http://java.sun.com/jsf/core" xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich"
xmlns:ui="http://java.sun.com/jsf/facelets">
<af:document title="untitled2.jsf" id="d1">
<af:form id="f1">
<a4j:form ajaxSubmit="true" reRender="content">
<panelGrid>
<af:menuBar id="mb1">
<af:menu text="menu 1" id="m1">
<af:commandMenuItem text="commandMenuItem 1" id="menuPage" actionListener="#{PageBean.getMenu}" action="menuPage.jsff">
<a4j:ajax execute="@form" render=":content"/>
</af:commandMenuItem>
</af:menu>
<af:menu text="menu 2" id="m2">
<af:commandMenuItem text="commandMenuItem 2" id="menuPage2" actionListener="#{PageBean.getMenu}" action="menuPage1.jsff">
<a4j:ajax execute="@form" render=":content"/>
</af:commandMenuItem>
</af:menu>
</af:menuBar>
<ui:insert name="content">
<ui:include src="#{PageBean.page}.jsff"/>
</ui:insert>
</panelGrid>
</a4j:form>
</af:form>
</af:document>
</f:view>
用于跟踪和更新用于显示页面的页面变量中的动态页面值的我的 actionListner Bean 是:-
PageBean(动作监听器的bean)
import javax.faces.event.ActionEvent;
public class PageBean {
String page = "menuPage";
public PageBean() {
}
public void getMenu(ActionEvent actionEvent) {
// Add event code here...
String id = actionEvent.getComponent().getId();
System.out.println(" Menu ID : "+id);
page = id;
}
public String getPage() {
return page;
}
}
现在我希望当我从 menu2 中单击 commanMenuItem2 时,将出现包含 outputText 值菜单页 2 的相关页面 menuPage2 而不是菜单页 1