The template used in most PHP frameworks (Cake, CI, ZF) is not simple MVC - it is Front Controller (and friends): you work with requests, route them, send them to actions, actions read request parameters, talk to the model, transfer data to the view, view the received answers and use some helpers to render the fragments that are used repeatedly, the answer ends, ends. A form in a typical PHP MVC application may result in a different action than the one it provided. The controller calls the view and has the ability to act until the view is displayed. Routing is important because actions are tied to URLs.
There is no such thing in JSF. Routing and redirection (at least what happens before the view is processed) are not part of the JSF, they are one level of abstraction below the JSF. You can add routing and forwarding using some other libraries or your own code, it's quite simple. The mechanism in faces-config.xml is not actually routed, and yes, you're right, it depends on the magic script. You do not use it to structure your web application (if only because it applies only to POST requests).
Actions in the JSF are not selected by the centralized router / dispatcher, but by components. In most cases, you don’t even need an action because the view and model are sufficient. You can imagine that JSF treats each page component as its own MVC stack. The component itself (for example, text input, a drop-down list) is responsible for returning data from the request, converting and validating data, displaying HTML and transmitting data to controllers (and other components) by placing them in the right place in the model.
Because of this, things that require an action controller, such as the Zend Framework, such as pagination, search, editing multi-page forms with custom presentation logic, etc., usually do not require more than a view and model in JSF (possibly validators or converters). Components trigger actions only when data is stored in the database or when data processing is complicated. Even then, the action is launched after the view has read all the data from the request, so sending the action is in no way connected with routing. Each commandlink or commandbutton must return to the exact page displaying the original form, because only the components on this page can understand the request and update the model. Since routing has nothing to do with shelling actions, it is left out of the box (you can do pretty URLs and pretty routing using libraries like PrettyFaces , but it's not part of JSF).
JSF redirects are performed as the result of actions (based on the string returned by the actions), therefore, although redirection and some logic can be performed before it, the template must be processed before redirection.
In PHP, it is customary to think of reading data from a database as an "action that needs to be done before the view is displayed." In JSF, this is not an action, but part of the initialization of your model; as such, it belongs to a method inside your bean-driven model — such a method must be annotated using @PostConstruct and it will be executed by the DI JSF container before you get the bean reference, and after all the dependencies have been entered.
If you really think you need to run an action before the page displays, use event listeners - but be careful: you might be doing something wrong.
The hidden assumption underlying the Cake / Zend structure is that "there is one main thing on every HTML page, and the display relates mainly to this one thing." JSF's hidden assumption is that "as far as we can tell, the whole application is just one page with control states"
If you have not invested too much time in JSF, you can first switch to JSR-311. This is a new alternative presentation layer for Java EE that focuses on a calm approach: quiet URLs, routing, resources, etc. It has pluggable templates, and its RI has a beautiful MVC level. If you like Zend Framework, you will like it. You can use JSR-311 to practice EJB, JPA, and other Java EE materials, and then return to JSF when you are already familiar with Injection Dependency, transaction management, etc., and can focus on stateful web presentations. An example code in Jersey (jsr-311 RI, you linked it to your glass fish / netbeans) might look like this:
@EJB UsersDao usersDao; @Path("/users/detail/{userId}") public void userDetail(@PathParam("userId") int userId){ return new Viewable("users/template.jsp", usersDao.getById(userId)); }
Warning: jsr-311 is service-oriented (json, xml), not a web application, and the template engine is connected, so there are no helpers of the jsr-311 type (when recovering URLs, you use it to a large extent yourself)