Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2005

Tip: Looking for answers? Try searching our database.

JSF and Servlet

Thread view: 
Liming - 14 Dec 2005 20:34 GMT
Hello all,

I had a few pages coded using pure JSF and everythign worked fine till
today...because one of the step has to forward to a servlet first and
then the servlet forwad back to the next JSF pages.

The problem is this.

Original page1->forward to->page2  using
(context.getExternalContext().dispatch(url) )

and on page2, there is a backbutton (immediate="true" to skip
validation phase) and goes back to page1. Before, if user filled out
someting on page2, go back to page 1 and come back again, those values
would be there. Now it doesn't. Anything that skipped validation
phase/model update phase, teh value is cleaned up.

I looked at the servelt, it has this.

ViewHandler vh = context.getApplication().getViewHandler();
context.setViewRoot(vh.createView(context, page));
lifecycle.render(context);

I suppose this cleared up the incompleted form values everytime. How do
I get around this?

Why did context.getExternalContext().dispatch(url) in my back bean
worked? and now this new code in the servelt?

Also fyi, i tried to comment out the lifecycle.render() method and
replaced it with context.getExternalContext().dispatch(url), but the
page goes through an infinit loop.

thanks.
Liming - 14 Dec 2005 23:09 GMT
Just to let you guys know it's solved.

The problem is with context.setViewRoot(vh.createview(context,page));

instead i should use context.setviewroot(vh.restorview(context,page));

The problem with restorview is that the first time when the page is
loaded, if you just call like that, lifecycle.render(context) will
throw an exception. so to handle it.. do this

                       try{
                               // try to restor the view. if fail, it
must be the first time. createView
                lifecycle.render(context);
            }
            catch(Exception e)
            {
                context.setViewRoot(vh.createView(context, page));
                lifecycle.render(context);   
            }


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.