19

I'm pretty new to JSF and reading some of the stack-answers like this one, I faced with the concept of view build time. Consider the JSF lifecycle scheme:

enter image description here

As you can see, there's no phase called view build time. Maybe it means the same as Restore view phase? From the JavaEE tutorial

During this phase, the JavaServer Faces implementation builds the view of the page [...]

Community
  • 1
  • 1
stella
  • 2,416
  • 1
  • 14
  • 29

1 Answers1

26

The view build time is not a phase. The view build time is that moment when the physical UIViewRoot instance and all of its children is built based on the view declaration, which is usally defined in XHTML or JSP files.

The view build time moment is not restricted to a specific JSF lifecycle phase. It can technically happen in any phase. By default, it's indeed usually executed during the restore view phase, but it can also happen during the render response phase, specifically when the request is a GET request, or when navigation has taken place during a POST request. Developers can also programmatically build the view via ViewDeclarationLanguage#buildView(), or implicitly force the JSF implementation to do that via FacesContext#setViewRoot(), when navigation isn't sufficient for the specific task.

The restore view phase just restores the JSF state into the view. I.e. it sets the component attributes with values as they were during the previous request on the same view. This way JSF knows exactly how the view looked like at the moment the form was being presented to the enduser and can among others do some safeguards against tampered requests.

See also:

Community
  • 1
  • 1
BalusC
  • 992,635
  • 352
  • 3,478
  • 3,452
  • 7
    As far as I got, in simple words building view means to create Java representation (i.e. Tree data structure) of the markup we declared. So, we just naturally map our xhtml page (which is the tree of tags by its nature) to the corresopnding Java tree data structure, where any component tag's being mapped to its component class. – stella Aug 08 '15 at 19:01