Thursday, September 6, 2012

Increase your JSF application performance (Part 2 - Design Patterns)

  • Use Facelets instead of JSP
  • If possible, always use HTML instead of JSF tags
  • Never put logic in getters because they can be called multiple times - especially for the rendered attribute
  • Avoid much logic in EL expression
  • Avoid using h:outputText. Just use EL expressions. If you need to escape HTML, it's better to use a EL function
  • Use AJAX as much as possible
  • Only process and update components which are really required to process or update
  • Cache data, which is required multiple times in the same view, in @RequestScoped beans
  • Avoid using @SessionScoped, @ViewScoped and other long living scopes
  • Split your beans. Its better to have a seperate bean for logic and a seperate bean for values which are required for multiple requests (@ViewScoped, @ViewAccessScoped...). I call them *Controller and *StateHolder