aspose file tools*
The moose likes JSF and the fly likes How to know the outcome of backing bean method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "How to know the outcome of backing bean method" Watch "How to know the outcome of backing bean method" New topic
Author

How to know the outcome of backing bean method

Ravi Mirani
Greenhorn

Joined: Aug 09, 2011
Posts: 19
I have called a managed bean which returns a string "GO_NEXT". I have added a navigation case in the faces-config.xml file for the same.



But still request is not forwarded to test.jsp.
How can I know whether the case I have given in the config file is correct or how I can print what saveDetails method has returned.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16305
    
  21

You can probably crank up the log levels for your JSF implementation and see the gory details, but I rarely get that desperate. The mechanism "just works", except when it doesn't, and then you don't usually get any error messages.

Several things can mess you up.

1. If the action method is never called, obviously it won't navigate. So you can put a trace print message in the action method to make sure it called. Or set a debugger breakpoint. The action method will only be called if all fields in the submitted form pass validation, so an "h:messages" tag on the page can point out any validation errors.

2. If there's no navigation handler for the outcome you indicate, it won't navigate. Not a problem in your case, though unless I missed something.

3. If the destination URL does not exist, it won't navigate. Note that I said URL and not "page definition", "file", or "resource". That's because JSF navigation is to a URL and URLs are NOT the same thing as files.

4. If the destination is not a JSF URL, it won't navigate. You can't pass from JSF to a JSP, for example using navigation. If the JSF page needs to advance to a JSP or servlet or non-JSF URL such as Struts, you can't do that in the action method via navigation. You'll have to do a forward in the action processor or use a "h:outputLink", depending on whether or not you have action processing to do.


Customer surveys are for companies who didn't pay proper attention to begin with.
Ravi Mirani
Greenhorn

Joined: Aug 09, 2011
Posts: 19
thanks for your reply.
I have created 2 jsp files. /test.jsp and company/x/y/firstview.jsp. On test.jsp I have provide a link and called method of ManagedBean which returns a string and navigates to company/x/y/firstview.jsp (using faces-config.xml). This works fine.
On firstview.jsp, I have used JSF tags and fileds (i.e. radio buttons, button etc) and are linked with managed bean. I have also provided a button on firstview.jsp which calls the action method of managed bean and as per business logic it should get navigated back to test.jsp.
Action method is called successfully, but the page is not navigated.
Can you please more detail on Point 4 that you have mentioned, or provide an external URL for detail reference.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to know the outcome of backing bean method