开发者

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜