JSF dynamic ui:include

Posted by Ray on Stack Overflow See other posts from Stack Overflow or by Ray
Published on 2012-11-10T08:54:15Z Indexed on 2012/11/10 11:01 UTC
Read the original article Hit count: 242

Filed under:
|
|

In my app I have tutor and student as roles of user. And I decide that main page for both will be the same. But menu will be different for tutors and users. I made to .xhtml page tutorMenu.xhtml and student.xhtml. And want in dependecy from role include menu. For whole page I use layout and just in every page change content "content part" in ui:composition.

In menu.xhtml

<h:body>
    <ui:composition>        
            <div class="menu_header">
                <h2>
                    <h:outputText value="#{msg['menu.title']}" />
                </h2>
            </div>
            <div class="menu_content">
                <?:if test="#{authenticationBean.user.role.roleId eq '2'}">
                    <ui:include src="/pages/content/body/student/studentMenu.xhtml"/>
                </?:if>

                <?:if test= "#{authenticationBean.user.role.roleId eq '1'}">
                    <ui:include src="/pages/content/body/tutor/tutorMenu.xhtml" />
                </?:if>
            </div>      
    </ui:composition> 

I know that using jstl my be not better solution but I can't find other. What is the best decision of my problem?

© Stack Overflow or respective owner

Related posts about jsf

Related posts about jsf-2