我想在单击特定的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页