【发布时间】:2014-05-16 18:36:30
【问题描述】:
我正在尝试根据 p:layout 中的选定操作动态加载页面 - 我的操作由托管 bean 驱动 - 使用下面的代码我看到托管 bean 被调用并且正确的页面被传递但没有得到呈现。想知道我错过了什么,希望有人能指出它。
谢谢
布局页面
<!DOCTYPE html>
<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:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<f:view contentType="text/html" locale="en">
<h:head title="Title">
<ui:insert name="head" />
</h:head>
<h:body>
<p:layout fullPage="true">
<p:layoutUnit position="north" size="100" header="Top"
resizable="true" closable="true" collapsible="true">
</p:layoutUnit>
<p:layoutUnit position="south" size="100" header="Bottom"
resizable="true" closable="true" collapsible="true">
</p:layoutUnit>
<p:layoutUnit position="west" size="200" style="width:200px"
header="Menu" resizable="true" closable="true" collapsible="true">
<h:form id="formMainMenu">
<p:panelMenu style="width:400px">
<p:submenu label="Sub Menu 1">
<p:submenu label="Sub Menu 2" icon="ui-icon-extlink">
<p:menuitem value="Option1"
actionListener="#{menuController.setPage('../../public/pages/aboutTest.xhtml')}"
update=":allLayoutForm:allLayout" />
</p:submenu>
</p:submenu>
</p:panelMenu>
</h:form>
</p:layoutUnit>
<p:layoutUnit position="east" size="200" header="Right"
resizable="true" closable="true" collapsible="true" effect="fade">
</p:layoutUnit>
<h:form id="allLayoutForm">
<p:layoutUnit position="center" id="allLayout">
<ui:insert name="content">src="#{menuController.page}"</ui:insert>
</p:layoutUnit>
</h:form>
</p:layout>
</h:body>
</f:view>
</html>
菜单控制器
@SuppressWarnings("unused")
@ManagedBean
@ViewScoped
public class MenuController {
private String page;
public String getPage() {
System.out.println(" Get "+page);
return page;
}
public void setPage(String page) {
System.out.println(page);
this.page = page;
}
}
【问题讨论】:
标签: jsf primefaces