This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSF and the fly likes Trying to change <ui:include> src tag dinamically Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Trying to change <ui:include> src tag dinamically" Watch "Trying to change <ui:include> src tag dinamically" New topic

Trying to change <ui:include> src tag dinamically

Vladislav Simovic
Ranch Hand

Joined: Feb 03, 2011
Posts: 37
I have main page that looks like this:

What i want to do is have a bean like this and change dinamically which page is included. This is how bean looks like:

When i click button Push i want this page to be included:

Problem is that i have to press the button twice for page to be included. How can this be done so when i press the button the first time page is included.
Krystian Gor
Ranch Hand

Joined: Jan 11, 2011
Posts: 30
I don't know how to do this but I can tell you why it happens.
If you use a getPage method like this you can observe what's going on.

<ui:include is using the first phase of JSF lifecycle to get value of #{}. So if you click commandButton it gets old value even before action method changePage is called. That's why it's always one click late. Seems like there is no way to do this with ui:include. Doesn't matter if you use Ajax or Primefaces, it's JSF thing.
It is sorta covered in the JavaRanch Style Guide.
subject: Trying to change <ui:include> src tag dinamically
Similar Threads
JSF 2.0 Login
Problem achieving masterpage functionality in JSF
Why events are not fired when value changes in h:selectOneMenu? I am stuck!
javax.el.PropertyNotFoundException: Objetivo inalcanzable - JSF - Facelet - method-signature
ui:repeat + AJAX