Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JSF and the fly likes JSF View Creation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "JSF View Creation" Watch "JSF View Creation" New topic
Author

JSF View Creation

An Me
Greenhorn

Joined: Nov 28, 2013
Posts: 10
Suppose on click of a h:commandButton in page1.xhtml navigates me to page2.xhtml .
Now on click,the request will be a postback and will be processed through lifecycle phases restore view,apply request values, process validations,update model values,invoke application and finally render response.Now in render response it comes the navigation handler finds that it need to go to a page2.xhtml.At this point, whether the view for page1.xhtml is cached and a new view is created for page2.xhtml and then rendered(which goes through create view and render response phases only)..??
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15964
    
  19

xhtml's are resources and JSF navigates URLs. So actually, it's page1.jsf and page2.jsf. The xhtml's only supply view template data. I do a lot of tiling, so my pages actually reference more than one xhtml per page.

The actual HTML is not cached. However, the component trees are, up to a certain limit (defined in web.xml).

If you start on page1, page1 constructs a component tree, binds it to that view's backing bean(s) (Model objects) and the renderer then converts it to HTML, which is sent back to the requester. The component tree itself is cached(*see below).

If the requester then submits another (postback) request to page1 whose action directs navigation to page2, the same process will be done for page2.

Now, if page2 navigates back to page1, the saved component tree for page 1 is retrieved and rendered using the current property values of its backing bean(s).

Note that there are 2 ways to preserve a component tree. One is server-side caching, which is the most common. The other is client-side, where the digested tree is serialized out and sent to the client, which sends it back when needed. Which method is used depends on your web.xml settings, although server-side is the default. Each method has certain advantages and disadvantages.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSF View Creation
 
Similar Threads
JSF LifeCycle Understanding problem
Need to understand the Request Scope
Page Forward in Portlets
What is an efficient way to implement an entirely AJAX based web app using JSF2?
Liferay Portlet with JSF Portlet bride-Problem