我有2个Facelets文件(index.xhtml和report.xhtml)。我使用RichFaces <ui:include src="report.xhtml"/>
将报告加载到索引中。工作正常。 但是,当我试图只显示某些条件的报告,我失败了!不起作用的是:有条件地包含一个Facelet文件通过<ui:include>
<ui:include src="report.xhtml" rendered="#{indexService.contentName == 'report'}"/>
。
ui:include的呈现属性似乎不起作用。
如何在特定条件下将report.xhtml加载到index.xhtml中?我的代码中的错误在哪里?
编辑:
的一半,现在的作品。更改Facelet文件适用于条件。但是加载的Facelet的功能无法正常工作。这是为什么?代码中的问题在哪里?
基础上的建议,我现在有这样的:
<h:form>
<h:panelGrid>
<a4j:commandLink value="Home" render="contentpanel" action="#{indexService.setContentName('home')}"/>
<a4j:commandLink value="Report" render="contentpanel" action="#{indexService.setContentName('report')}"/>
</h:panelGrid>
</h:form>
<a4j:outputPanel id="contentpanel">
<ui:fragment rendered="#{indexService.contentName eq 'report'}">
<ui:include src="report.xhtml" />
</ui:fragment>
</a4j:outputPanel>
编辑2:
这是我的报告的facelet。如果我在没有任何条件的情况下使用,报告Facelet的功能完美地工作,但是如果使用我发布在编辑1中的条件加载它,则<rich:panelMenuItem .../>
的按钮不再工作,<h:outputText escape="false" value="#{reportService.content}"/>
不会加载内容。任何想法为什么?
编辑3:
改变了<rich:panel header="Report">...</rich:panel>
,但仍表现持平。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j">
<ui:composition>
<h:outputStylesheet>
.placesmenu {
width: 200px;
vertical-align: top;
}
.contentplace {
vertical-align: top;
}
</h:outputStylesheet>
<h:panelGrid columns="2" width="100%" columnClasses="placesmenu, contentplace">
<rich:panel header="Places">
<h:form>
<rich:panelMenu style="width: 170px">
<a4j:repeat value="#{reportService.menuItems}" var="menuItem" id="repeat_layer1">
<rich:panelMenuGroup label="#{menuItem.label}">
<a4j:repeat value="#{menuItem.subMenuItemList}" var="subMenuItem" id="repeat_layer2">
<rich:panelMenuItem label="#{subMenuItem.label}" render="reportpanel" onbeforedomupdate="#{reportService.setId(subMenuItem.id)}"/>
</a4j:repeat>
</rich:panelMenuGroup>
</a4j:repeat>
</rich:panelMenu>
</h:form>
</rich:panel>
<rich:panel header="Report">
<h:outputText escape="false" value="#{reportService.content}" id="reportpanel"/>
</rich:panel>
</h:panelGrid>
</ui:composition>
</html>
我使用的编程NetBeans和它提示我说。 – Socrates 2014-10-16 14:15:25