eugui
eugui

Reputation: 471

Dynamic ui:include in JSF

I have this code in JSF:

<ui:include rendered="#{paginaMB.pagina eq 'login'}" id="paginaSistema" src="/login.xhtml" />
<ui:include rendered="#{paginaMB.pagina eq 'noticias'}" id="paginaSistema" src="/noticias.xhtml" />

I don't know why using "rendered" both pages are displayed.

If I use this code:

<ui:include id="paginaSistema" src="#{paginaMB.pagina}.xhtml" />

the problem was solved but I have a button inside login.xhtml that uses managed bean and the managed bean is not found, no action is taken when I click on it.

How can I solve this dynamic include?

Upvotes: 2

Views: 607

Answers (1)

Kasper Ziemianek
Kasper Ziemianek

Reputation: 1345

ui:include doesn't have attribute rendered

You should use ui:fragment.

<ui:fragment rendered="#{paginaMB.pagina eq 'login'}">
  <ui:include id="paginaSistema" src="/login.xhtml" />
</ui:fragment>

Upvotes: 2

Related Questions