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 control the running order of different back bean functions 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 "control the running order of different back bean functions" Watch "control the running order of different back bean functions" New topic

control the running order of different back bean functions

reubin haz
Ranch Hand

Joined: May 12, 2005
Posts: 287
I'm using JSF 1.1 to create a web app.
In a page, I have a link, when you click it, it will switch between English and French, and so does the rest of content on the page.

But I found a table's header is switching one step behind for language change, that is, when I click French, the table header is still showing English. When I click English, the table header shows French. If I refresh the page, the table header shows correctly then. (Table header is loaded from DB with both English and French column)

The code for the link is this:

I have a java class, say as the back bean for the table and other content.
So how should I control that localeChanger.onChooseLocale is always running first before tableSummary back bean class get executed? Since I need set the session value for locale in LocaleChanger class first, then I will need get value in TableSummary class. Even through the link is written before the table header and content, I found session is set after the table reloaded...


Mole Moore

Joined: Apr 03, 2009
Posts: 6
Hello reubin,
I am new to JSF, so please take this with a grain of salt. I am kind of hoping that those more experienced in JSF will let me know of a better way to do this.

I had a need to perform some first-time logic before any code in my backing bean was ran. This seems to be kind of what you are needing to do? Lookup a value from a database and place it in session before some other code is ran?

Assuming that is correct, I used a PhaseListener that gets fired before any processing in my backing bean is done.

Two things are needed to use a PhaseListener, first a class that implement the JSF PhaseListener interface and an entry in faces-config.xml to register your listener with JSF.

Your PhaseListener class:

Register your listener with JSF.


This probably is not the best solution out there, but it does the job very well.

reubin haz
Ranch Hand

Joined: May 12, 2005
Posts: 287
thanks for the reply.
But for my scenario, my firstTimeLogic() is actually the constructor of my back bean class, which is supposed to be called from JSF container when the page is loaded. So I cannot really instantiate my back bean class inside firstTimeLogic() method...
I agree. Here's the link:
subject: control the running order of different back bean functions
Similar Threads
h:commandLink will not work inside a h:dataTable
Action method not getting called inside the dataTable
Can not Invoke actionLister - DataTable of Links
datatable commandlink action method called for each row
tomcat-users.xml login