Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><em>In the MVC pattern, what is model component in the JSF? Is it the Managed Bean?</em></p> <p>I suggest this:</p> <p>VIEW LAYER (consists of a mini MVC):</p> <p>userForm.xhtml &lt;-- view; the web page</p> <p>UserController &lt;-- controller; a managed bean</p> <p>UserController.get/setUser &lt;-- model; the model for the view</p> <p>CONTROLLER LAYER:</p> <p>UserService &lt;-- controller; the controller that contains CRUD related business logic</p> <p>UserDAO &lt;-- persists objects to the database</p> <p>User &lt;-- the domain object that gets persisted</p> <p>MODEL LAYER:</p> <p>The database</p> <p><em>Is it good idea to write the business logic in the action methods? I have seen hundreds of lines written in action methods.</em></p> <p>In my example, put the business logic in the methods of the UserService. The action method of UserController doesn't do much more than call the method in the UserService, catch any exceptions and format the response for the next web page that is displayed.</p> <p><em>Do you think that we can write any logic in the getter methods?. How many times getter or setter called in the JSF lifecycle.</em></p> <p>Preferable for getter/setters to just do the getting/setting. No logic.</p> <p><em>What is the conventional way of writing the faces-config.xml. I have read in one document that it says good practice to write the managed bean declaration and navigation case for that bean together. It will be more readable.</em></p> <p>I declare all of my managed beans together. And declare all of my navigation rules together.</p> <p><em>Writng the phase listener would affect the response time. For example, I am writing a logic to parse the request parameter in the PhaseListener and doing some logic. Is there any advice on this?</em></p> <p>Not sure what you're doing exactly, but you shouldn't have to manually parse request parameters. JSF should inject the values of your form directly into the model of the view for you. Maybe I need more info about what you're trying to do.</p> <p>Hope this helps.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload