I am new to JSF (2).
In Struts we can invoke an action from a URL like app.action. This invokes an action and returns a result page, say a JSP (initiall
If it's preparing data for an initial GET request, just do the job in (post)constructor of the request or view scoped managed bean associated with the page.
@ManagedBean
@RequestScoped
public class Bean {
public Bean() {
// Here.
}
@PostConstruct
public void init(){
// Or here, certainly if you rely on injected dependencies like @EJB.
}
}
If it's controlling the request/response and may possibly redirect/navigate to another page, then do the job in preRenderView.
with
public void listener() {
// ...
// You want to redirect?
externalContext.redirect(newURL);
// Or you want to navigate?
navigationHandler.handleNavigation(context, null, "newOutcome");
}
Or if you want to hook on all requests, then use a filter:
@WebFilter("/*")
public class MyFilter implements Filter {
// ...
}