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);
}