| Author |
Error after navigation
|
Ravi Mirani
Greenhorn
Joined: Aug 09, 2011
Posts: 19
|
|
I have 2 xhtml files mypage.xhtml, page1.xtml.
On mypage.xhtml I am calling a managed bean method which returns "PAGE1". I have also defined the necessary navigation rule in faces-config.xml.
Below is code
myMB in the above code is of viewscope and returan String as "PAGE1".
Clicking on link of mypage,xhtml , user is navigated to page1.xhtml but in <ice:messages /> I am getting below mentioned error
Unable to find matching navigation case with from-view-id 'user/page1.xhtml' for action '#{myMB.getPageOutCome()}' with outcome 'PAGE1'.
|
 |
Ravi Mirani
Greenhorn
Joined: Aug 09, 2011
Posts: 19
|
|
|
Please provide help on this issue....
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14475
|
|
Like so many people, you are making the fatal mistake of confusing a resource path with a URL.
The view definition resource file extension is ".xhtml", but the JSF navigation system doesn't want the resource, it wants a JSF relative URL.
In other words, not "user/mypage.xhtml", but "/user/mypage.jsf". Not "user/page1.xhtml", but "/user/page1.jsf".
|
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 made given changes, but now I am not able to navigate to page1.xhtml.
I am not sure whether I have implemented this correctly, hence request you to correct me, if I am wrong.
in web.xml
Please also let me know if there is page2.xml which is in another folder e.g. webcontent/abc/page2.xhtml and I want to call page2.xhtml instead of page1.xhtml, what should I specify in <to-view-id> tag.
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14475
|
|
You are still using a resource path instead of a URL on the from-view-id. Because that doesn't match the actual page URL, the entire navigation rule is ignored.
The from-view-id is optional, BTW. If you want the from-action to navigate regardless of what page it was invoked from, you can omit the from-view-id.
|
 |
Ravi Mirani
Greenhorn
Joined: Aug 09, 2011
Posts: 19
|
|
Thanks for you reply.
I did the changes suggested by you, but issue still pending.
I don't think so that navigation rule is not found by the controller (even if I give file extention as .xhtml in faces-config), as user is sucessfully navigated to the page given in the <to-view-id>.
But after he is navigated to that page he gets an error
Unable to find matching navigation case with from-view-id '/user/page1.xhtml' for action '#{myMB.getPageOutCome()}' with outcome 'PAGE1'
.
I m not able to understand why in above message from-view-id in quotes is displayed as to-view-id of face-config.xml file.
Please help me in understanding how exactly this works.
Note:
One of previously reported issue (http://www.coderanch.com/t/569753/JSF/java/calling-javascript-function-after-execution) got resoved after I started specifying value in from-view-id instead of * sign.
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14475
|
|
xhtml files are Facelets resources. I suspect that you did not properly configure Facelets in web.xml.
In case you are thinking that myMB is a Controller, it is not. It is a Model. The Controller is the FacesServlet, and it is the FacesServlet that does the page navigation.
The way to match any "from-view-id" is not to use "*" as the ID, but to simply remove it completely. If no from-view-id is specified, then ALL from-views are valid.
The action= attribute is NOT a method call. It is an expression that names the action method in the backing bean. So remove the "()".
And finally, I repeat that a view-id is a URL and not a file resource, so the extension would be ".jsf", not ".xhtml".
|
 |
Ravi Mirani
Greenhorn
Joined: Aug 09, 2011
Posts: 19
|
|
Yes you might be correct, I might have made some mistake while configuring web.xml.
Can you please provide me what entries should be there in web.xml file for ICEFaces 3.0.
I agree to your point that FacesServlet is the controller and not myMB.
Is there any specific class in ICEFaces 3.0 which I should mention in web.xml as my Controller for all *.jsf resources.
Please also let me know if there is page2.xml which is in another folder e.g. webcontent/abc/page2.xhtml and I want to call page2.xhtml instead of page1.xhtml, what should I specify in <to-view-id> tag.
Thanks for replying my quries.
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14475
|
|
The dispatcher functionality is independent of whether or not you use IceFaces, so any good JSF reference will help you on that.
There are 3 things that are critical, however.
1. You must configure web.xml to route URLs that end with ".jsf" to the FacesServlet.
2. You should ensure that when the FacesServlet receives a JSF URL that it converts the URL's resource path component to find the facelet View Definition (.xhtml)
3. You must either include a Facelets jar in your WAR or use a webapp server that supports the full JSF2 stack (facelets is an integral part of JSF2).
The JSF URL that locates page2 for your example would be "/webcontent/abc/page2.jsf". That's assuming that "webcontent" is the name of a folder within your WAR and not the name of the WAR itself. Otherwise it would be "/abc/page2.jsf".
|
 |
 |
|
|
subject: Error after navigation
|
|
|