title: Backing bean organization in JSF
body: <p>I have been thinking about this for a while now and have yet to come up with a best practice for how to organize my beans/classes in a JSF project for the presentation tier.  Obviously there are many factors that come into play, but I would like to discuss.  Here is my current line of thought:</p>
  
  <p>Consider a basic JSF (still stuck on JSF 1.xx here unfortunately) application that contains a view page (view the data) and an edit page (add, update, delete the data).  Here is how I would organize the project:</p>
  
  <p>Request scoped BackingBean:</p>
  
  <ul>
  <li>View related stuff (save status, render logic, etc.). Stuff that is only needed in one request</li>
  <li>Actions, action listeners, and value change listeners.  If they are applicable to more than one view, they can be separated into their own file.</li>
  </ul>
  
  <p>Session scoped BackingBean:</p>
  
  <ul>
  <li>Anything that needs to remain around longer than one request.  Database data, SelectItems, etc. </li>
  <li>This bean is injected into the request bean, and stores instances of any data objects</li>
  </ul>
  
  <p>Data Objects:</p>
  
  <ul>
  <li>It doesn't seem to make sense to make the data objects into beans, so they are stored separately.  This would be things like User, Book, Car, any object that you are going to display on the page.  The object can contain view helper methods as well such as getFormattedName(), etc.</li>
  </ul>
  
  <p>DAO:</p>
  
  <ul>
  <li>A non-bean object that handles all interaction with the business logic tier.  It loads the data bean and prepares submits, etc.  I usually make this a class of public static methods.</li>
  </ul>
  
  <p>Converters, Validators:</p>
  
  <ul>
  <li>Separate files</li>
  </ul>
  
  <p>This seems to be all that is needed in your average JSF application.  I have read through this: <a href="http://java.dzone.com/articles/making-distinctions-between" rel="nofollow noreferrer">http://java.dzone.com/articles/making-distinctions-between</a>, as well the replies here: <a href="https://stackoverflow.com/questions/746047/jsf-backing-bean-structure-best-practices">JSF backing bean structure (best practices)</a>, but I never felt like we got a complete picture.  BalusC's response was helpful, but didn't seem to quite cover a full app.  Let me know your thoughts!</p>