This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques and have Mario Casciaro & Luciano Mammino on-line!
See this thread for details.
Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Error after navigation

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please provide help on this issue....
 
Saloon Keeper
Posts: 24334
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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".
 
Ravi Mirani
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 24334
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 (https://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
Posts: 24334
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 24334
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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".
 
Surfs up space ponies, I'm making gravy without this lumpy, tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic