简体   繁体   中英

Dynamic incude page in xhtml page

I have a favourites chart, on click on an item in the chart, I have to inlcude a page in rich:tab. The favourites chart is built using jQuery and on each leaf click event I do a ui:include with jstl check. Please find the below code.

    <rich:tabPanel>
        <rich:tab label="#{mnOrdrMsgs.mainordr}" immediate="true"
            id="mainorderTab" styleClass="tabPanel">

            <c:if test="${favouritesBean.selectedNaviItem != null}">
                <ui:include src="#{favouritesBean.selectedPage}" />
            </c:if>

            </rich:tab>
        <rich:tab label="#{mnOrdrMsgs.archiv}" immediate="true"
            id="archivTab" styleClass="tabPanel">
        Archive
    </rich:tab>
    </rich:tabPanel>

The problem is the value of favouritesBean.selectedPage is always null. Can anyone please help in this case. I am really stuck since 2 days.

"I think the problem come from the assignement of favouritesBean.selectedNaviItem."

The bean attribute selectedNaviItem is null for the first time render phase hence the selectedNaviItem is not evaluated and by default always the selectedPage value is being displayed.

Solution:

Initialise the bean with empty string or default value.

JSTL tags doesn't run in sync with JSF tags as you'd expect from the coding. JSTL tags are executed during JSF view build time which produces a tree with JSF tags only. JSF tags are executed during JSF view render time which produces a tree with HTML elements only.

In this particular case, you want to use a JSF tag instead. Use <ui:fragment> or <h:panelGroup> .

<ui:fragment rendered="#{favouritesBean.selectedNaviItem != null}">
    <ui:include src="#{favouritesBean.selectedPage}" />
</ui:fragment>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM