myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Calvin Hill <chillth...@gmail.com>
Subject Re: Failing to take control of navigation
Date Wed, 27 Dec 2006 14:43:04 GMT
Hello,

I have had a similar problem but not using JSF.  I was using a home  
grown MVC application.  The problem I experienced was doing a request  
using a specific URI.  The URI was like so "webapp/somePage.jsp".  I  
was able to fix it by changing it to "/webapp/somePage.jsp".  The  
first time you can get to that page just fine.  But any subsequent  
time you could not.  I don't know if these are two entirely different  
problems that cause the same effect or what.

The next question I would ask is, on a refresh or clicking the href a  
second time are you able to step through your servlet filter again?   
Was there something in request scope on the first click but when you  
do a refresh or the href click, that something is no longer there?   
You are dying on the JSF page you were forward too; so I bet you are  
getting to the filter.

Calvin Hill
return Programmer.someType()




On Dec 27, 2006, at 7:36 AM, yuvalgo wrote:

>
> Hi,
> Im trying to take control of the navigation.
> let me explain:
> I wish to have my own piece of code to parse the request URI and  
> control the
> navigation to the next JSF page.
> This functionality is desired for accomplishing a permalinks scheme  
> of some
> sort.
> For example
>
> The link root/yuval/yuvals_stuff should cause the following to happen:
>
> - I parse the request with a servlet filter and know that we need  
> to load
> some data for yuval.
> - I use a ViewHandler to load the data (it delegates the call to some
> service that gets the data from the database)
> - I now forward the user to a known jsf page that is bounded with the
> viehandler and presents yuval's stuff .
>
> Actually, the first time i try to use the code, the navigation goes  
> well.
> But right after refresh or calling the same url again I get an  
> exception.
> The code and the exception are provided here:
>
>
> Here is what i do inside a servlet filter (I also tried to put this  
> code
> inside the faces servlet, just for testing):
>
> <code>
> FacesContext fc = FacesUtils.getFacesContext(req, res);
> 			
> String action = "#{viewPollViewHandler.go2}";
> 			
> javax.faces.application.Application application = fc.getApplication();
> MethodBinding mb =
> application.createMethodBinding("#{viewPollViewHandler.go2}",null);
> String outcome = (String)mb.invoke(fc, null);
> 			
> String fromAction = mb.getExpressionString();
> NavigationHandler navigationHandler =  
> application.getNavigationHandler();
> navigationHandler.handleNavigation(fc, fromAction, outcome);
> String viewId = fc.getViewRoot().getViewId();
> UIViewRoot view = fc.getApplication().getViewHandler().createView(fc,
> viewId);
> view.setViewId(viewId);
> fc.setViewRoot(view);
>
> fc.getExternalContext().dispatch(viewId);
> fc.responseComplete();
> </code>
>
> Explanation:
>
> First we try to get the FacesContext, using the current request and  
> response
> objects. Now we know what action we want to invoke on what  
> ViewHandler, so
> we go ahead and make a method binding for this method through the JSF
> Application context. Now we invoke the method and get the outcome  
> String
> from it. Till now everything seems to work ok – we get the  
> ViewHandler's
> method invoked correctly and we get the proper outcome String from it.
> This means the ViewHandler is now populated with our needed data,  
> so all we
> have left to do is go to the presentation page that uses this  
> ViewHandler.
> We use JSF's NavigationHandler to navigate as usual, giving it a
> "fromAction" and an outcome. Now we want the name of the page for this
> navigation, so we get the view id from the FacesContext. The view  
> id is
> correct and points to the next page as states in the faces- 
> navigation.xml,
> so we set it as the new view root and try to "dispatch()" (which is  
> the same
> as "forward()") to it.
> The result seems sufficient, as we get to the next page and all the  
> data is
> presented correctly (sometimes, in IE only we experienced some  
> javascript
> errors that were unknown). The big problem occurs when trying to hit
> "REFRESH" or clicking back and then trying the original href link  
> again. We
> suddenly get a NullPointerException that occurred in the "getValue 
> ()" method
> of JSF's getValueBinding()".
>
> Can anyone contribute?
>
> Thank in advance!
> Yuval.
>
> -- 
> View this message in context: http://www.nabble.com/Failing-to-take- 
> control-of-navigation-tf2886114.html#a8062889
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>


Mime
View raw message