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 TableSummary.java 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...
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.
This probably is not the best solution out there, but it does the job very well.
Joined: May 12, 2005
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...
subject: control the running order of different back bean functions