0

I have 2 Facelets files (index.xhtml and report.xhtml). I use the RichFaces <ui:include src="report.xhtml"/> to load the report into the index. Works fine. But when I try to only show report on certain conditions, I fail! What does not work is this:

<ui:include src="report.xhtml" rendered="#{indexService.contentName == 'report'}"/>.

The rendered attribute of ui:include does not seem to work.

How can I load the report.xhtml into the index.xhtml on certain conditions? Where is the error in my code?

Edit:

Half of it works now. Changing the Facelet file works with conditions. But the functionality of the loaded Facelet does not work properly. Why is that? Where is the problem in the code?

Based on the suggestions I now have this:

<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>

Edit 2:

This is my report Facelet. If I use without any condition the functionality of the report Facelet works perfectly, but if I load it using the condition I posted in Edit 1, then the buttons of <rich:panelMenuItem .../> don't work anymore and <h:outputText escape="false" value="#{reportService.content}"/> does not load the content. Any idea why?

Edit 3:

Changed the <rich:panel header="Report">...</rich:panel>, but behaviour still unchanged.

<!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>
Socrates
  • 8,724
  • 25
  • 66
  • 113

1 Answers1

5

try to surround your ui:include tag with ui:fragment as follows :-

<ui:fragment rendered="#{indexService.contentName eq 'report'}">
     <ui:include src="report.xhtml" /> 
</ui:fragment>
Scorpion
  • 577
  • 4
  • 21
  • Thanks a lot for the quick answer. It now works half. I posted my current status in my main posting. Pls have a look. – Socrates Oct 16 '14 at 14:13
  • can you explain what your business do and what you expect from the included page to do !? – Scorpion Oct 16 '14 at 14:22
  • Ok. Well, pretty easy thing actually. I have Facelets for Reports, Photos, Memo, ... Within the Index Facelet I bring them together. So for each I have one link I wanna click to then load the appropriate one. That's about it. Pretty easy, as said. Why do you ask that? Is my approach completely wrong? – Socrates Oct 16 '14 at 14:33
  • Posted **Edit 2** for understanding what I do. Pls have a look. – Socrates Oct 16 '14 at 14:47
  • @user3164889 as i understand your words if you want to update the content of tag you must give it an 'id' and render it using this id. – Scorpion Oct 16 '14 at 14:57
  • Changed it according to your suggestion. Behaviour unchanged though. Where is the error in the code? I still have no idea what to change. I have tried so many things already, but all lead to the same result yet. – Socrates Oct 17 '14 at 11:04