• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSF FacesContext extracting the action of <a4j:commandLink

 
Richard Roszak
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible on the server using the FacesContext to find the the action from a <a4j:commandLink ?

Thanks
 
Tim Holloway
Bartender
Posts: 18418
60
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm guessing that you want server-side code to read faces-config (as internally compiled) to obtain the descriptive information relating to an action. And the answer is probably yes, although it may be pretty complicated.

Since that's actually working uphill relative to the normal processing, I have to ask what the intended benefits are going to be. You may be looking at a hard solution for a simple problem!
 
Richard Roszak
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The question came up because I observed that after a successful login my application goes to a home.jsf page. Getting to that page involves calling no method. The application looks thru the faces-config.xml finds the managed bean for the home.jsf page which is the HomeController and calls it's constructor. The constructor in turn calls a showHomePage method. Is there anyway to get Faces to call the showHomePage method from outside the constructor directly after the login or is this always the navigation faces uses for the initial page?

Thanks.
 
Tim Holloway
Bartender
Posts: 18418
60
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If, as I suspect, you're using a home-grown security system like far too many people do, instead of taking advantage of the security package that comes with J2EE, navigation is likely to be the least of your worries. But I've ranted on that topic in other places.

JSF was designed with the idea that backing beans would be as framework-independent as possible, which is why I often comment that the fewer javax.faces imports in a bean, the better. JSF is based on MVC, and MVC expects the controller to manage navigation, not the model. At best, the model should only present data that helps the controller, as the JSF action methods do.

A constructor is not an action method, and in fact, couldn't return a navigation hint if it wanted to, since constructors can't return data, only initialize the object in question. It's important to remember also that in JSF you don't "call" a bean, you invoke a View, and that view may reference 1 bean (Model) or multiple beans (multiple Models). Or no beans, but that rarely accomplishes much. Unlike the set/get method and the action processors, the constructor is invoked only when JSF determines that no prior instance of the bean exists within the indicated scope so it needs to construct one. Session beans, in particular are constructed at reference time, not definition time, and that can be long before a login has been attempted in some cases, since a session is NOT equal to being "logged in" in the standard security framework, at least.

I realize that none of the above is The Answer, but they are the rules under which you are constrained by the JSF framework, so keeping them in mind is important while you attempt to find the answer.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!