• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

control the running order of different back bean functions

 
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...

Thanks.
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

faces-config.xml:


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

Mark
 
reubin haz
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
reply
    Bookmark Topic Watch Topic
  • New Topic