On 4/27/06, 王曾wang_zeng <[EMAIL PROTECTED]> wrote:
>
> In JSF, when a request arrives, it should go through 6 phases to process
> the
> request. The first stage is called Restore the View , and the last stage
> is
> called Render the Response. I wonder where JSP works in these 6
> phases.  If
> JSP only works in the last phase,


Which is, indeed, exactly how it works.

how can JSF restore the view first time
> the user view the page with no existing component tree in the session,
> because the information about the definition of the tree resides in the
> JSP
> by the form of JSF tags.  So I think maybe both the *Restore the View* and
> *Render the Response* need JSP to be involved.


You are correct.  There is special handling defined in the Restore View
phase.  If that phase discovers that there is no state to be restored
(either because this is an initial request for the welcome page, or because
this is a GET request for some other page accessed via a redirect or a
bookmark), then JSF will immediately forward to Render Response phase.

So, how do you make sure that the right dynamic data gets loaded so that the
page displays the right stuff?  That's where Shale comes in handy.  If your
backing bean implements the ViewController interface, then prerender() will
get called just before the JSP page is invoked.  This is the perfect place
to grab any data you need from your database to display the requested page.

You can do this without Shale, but there's somewhat more pain involved.
Better to have the framework tell you "Hey, I am about to render this page,
do you need to set up any state?".  In a Struts 1.x world, this corresponds
to the kind of stuff you might do in a setup action.

--
> Wang Zeng
>
>
Craig

Reply via email to