This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes JSF and the fly likes Problem in setting view root in beforeRenderResponse() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSF
Bookmark "Problem in setting view root in beforeRenderResponse()" Watch "Problem in setting view root in beforeRenderResponse()" New topic
Author

Problem in setting view root in beforeRenderResponse()

Dushyant Agarwal
Ranch Hand

Joined: Oct 14, 2007
Posts: 75
Hi,
I am developing an application in which a JSF page - pageA.jsp, has a backing bean PageA.java. pageA.jsp has an <f:phaseListener > tag . PageA.java implements PhaseListenerand has got the follwoing code in beforeRenderResponse() method :

public void beforePhase(PhaseEvent e){

if(e.getPhaseId().equals(PahseId.RENDER_RESPONSE))
beforeRenderResponse();


}

public void beforeRenderResponse(){
(FacesContext.getCurrentInstance().setViewRoot(
(HttpSession)
( FacesContext.getCurrentInstance().getExternalContext().getSession(true)
)
.getAttribute("savedViewOfPageB")
);
}

The "savedViewOfPageB" label is mapped to the UIViewRoot instance of another JSF page - pageB.jsp. And it is saved in an action method called in pageB's Backing Bean, when a command button is clicked in pageB.jsp. As well as there is navigation from pageB to pageA.

So now there Navigation pageB==>pageA & the view root of pageB is saved on session which has got to be displayed as soon as the rendering of pageA takes place.

But the view root of pageA does not get changed(to that of pageB) on initial request. If I make a postback on pageA then the new view(that of pageB) gets rendered. How can I change the view root of pageA to that of pageB in beforeRenderResponse
 
GeeCON Prague 2014
 
subject: Problem in setting view root in beforeRenderResponse()