• 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
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Specific method for bean JSF!

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,

I'm new developing with JSF and I want to know if there is a way I could write a method that will be called every time a request comes in. My bean is in the session scope! So, I can't write this code in the constructor because it will be called only once.

Turn the bean scope to request is not a option! I need the bean for the session.

There's another approach I can use to do this?!


Thanks!
Francisco.
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Francisco,

Following is a not so neat solution (i am looking for some extension point in framework but haven't found it yet).

Request scoped values can be kept in a different bean and request specific logic can be invoked in Constructor or last setter of the bean. This bean cannot be set as a managed property in session scoped bean and hence will have to looked up in session bean as



Hope it helps.

Warm Regards
Ravindra
 
Saloon Keeper
Posts: 28822
212
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just for info, this is what the Aspect-Oriented Programming people call a "cross-cutting" concern. I haven't tried AOP+JSF, however, except to the degree that the Spring framework helps out my data persistence.
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Make your own action listener and configure JSF to use it as the default action listener.

Inside the listener check the bean name and through reflection (or cast it) call the method you want.
 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Could you not use the shale framework?

So you could use the view controller as the base controller of your session beans and then make use of the prerender or init methods?

John
 
Here. Have a potato. I grew it in my armpit. And from my other armpit, this tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic