我已成功实施此问题中给出的解决方案 - > How to ajax-refresh dynamic include content by navigation menu? (JSF SPA)。但是,我想使用rich:panelMenu进行导航。因此,我不想使用h:commandLink,而是使用rich:panelMenuItem。所以不要使用下面的代码......
<h:panelGroup id="menu" layout="block">
<h:form>
<f:ajax render=":content">
<ul>
<li><h:commandLink value="include1" action="#{bean.setPage('include1')}" /></li>
<li><h:commandLink value="include2" action="#{bean.setPage('include2')}" /></li>
<li><h:commandLink value="include3" action="#{bean.setPage('include3')}" /></li>
</ul>
</f:ajax>
</h:form>
</h:panelGroup>
<h:panelGroup id="content" layout="block">
<ui:include src="/WEB-INF/includes/#{bean.page}.xhtml" />
</h:panelGroup>
.....我想拥有......
<h:panelGroup id="menu" layout="block">
<h:form>
<rich:panelMenu>
<rich:panelMenuGroup label="Group 1">
<rich:panelMenuItem label="include1" action="#{bean.setPage('include1')}" />
<rich:panelMenuItem label="include2" action="#{bean.setPage('include2')}" />
<rich:panelMenuItem label="include3" action="#{bean.setPage('include3')}" />
</rich:panelMenuGroup>
</rich:panelMenu>
</h:form>
</h:panelGroup>
<h:panelGroup id="content" layout="block">
<ui:include src="/WEB-INF/includes/#{bean.page}.xhtml" />
</h:panelGroup>
bean在示例中实现,即....
@ManagedBean
@ViewScoped
public class Bean implements Serializable {
private String page;
@PostConstruct
public void init() {
page = "include1"; // Default include.
}
// +getter+setter.
}
由于某些原因,rich:panelMenuItem方式无效。我能做错什么?