Java. Server Faces: Sample App + Life Cycle Compiled from Sun Tech. Days workshops (JSF Basics, Web-Tier Codecamp: Java. Server Faces, Java Studio Creator)
Sample JSF Application l guess. Number application that comes with JSF 1. 0 as part of J 2 EE 1. 4 SDK l Guess a number between 0 and 10, inclusive ¡The response page tells you if you guessed correctly l • Input validation
Starting Page
Failure Outcome Navigation
Success Outcome Navigation
Input Validation Error
Lifecycle of JSF Page l A JSF page is represented by a tree of UI components, called a view l When a client makes a request for the page, the lifecycle starts l During the lifecycle, JSF implementation must build the view while considering state saved from the previous postback l When the client performs a postback of the page, JSF implementation must perform lifecycle steps ¡ validation ¡ conversion
Request Processing Lifecycle Phases l 1. Reconstitute component tree phase l 2. Apply request values phase l 3. Process validations phase l 4. Update model values phase l 5. Invoke application phase l 6. Render response phase
Request Processing l Life-cycle handles two types of requests ¡ Initial request & Postback l Initial request ¡ A user requests the page for the first time ¡ Lifecycle only executes the Restore View and Render Response phases l Postback ¡ A user submits the form contained on a page that was previously loaded into the browser as a result of executing an initial request ¡ Lifecycle executes all phases