You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Anthony Hong <an...@gmail.com> on 2006/03/02 15:19:33 UTC

JSF navigation url problem

In JSF navigation rule, show as following

<navigation-rule>
    <from-view-id>/pages/inputname.jsp</from-view-id>
    <navigation-case>
      <from-outcome>sayHello</from-outcome>
      <to-view-id>/pages/greeting.jsp</to-view-id>
    </navigation-case>
    <navigation-case>
      <from-outcome>sayGoodbye</from-outcome>
      <to-view-id>/pages/goodbye.jsp</to-view-id>
    </navigation-case>
  </navigation-rule>

In this example, click button in inputname.jsp can change page to
greeting.jsp, but the url in IE has no change, means it is as same
"inputname.jsp", click link in greeting.jsp to goodbye.jsp, url in IE
is "greeting.jsp"
Seams it is always one step after current page. it works fine by click
link. but if I refresh current page, it displayed previous page not
current page.
This can be solved by add <redirect/> in each navigation-case. But why
default action has such problem? What is the purpose?


--

Anthony Hong

Re: JSF navigation url problem

Posted by Iryna Stetska <is...@lohika.com>.
Hello Anthony,

I've been fighting with this problem for long.
I'm afraid you cannot be offered any good solution now.

Look here http://issues.apache.org/jira/browse/TOBAGO-2 for our
company's ideas on how to solve it.


Thursday, March 2, 2006, 4:19:33 PM, you wrote:

> In JSF navigation rule, show as following

> <navigation-rule>
>     <from-view-id>/pages/inputname.jsp</from-view-id>
>     <navigation-case>
>       <from-outcome>sayHello</from-outcome>
>       <to-view-id>/pages/greeting.jsp</to-view-id>
>     </navigation-case>
>     <navigation-case>
>       <from-outcome>sayGoodbye</from-outcome>
>       <to-view-id>/pages/goodbye.jsp</to-view-id>
>     </navigation-case>
>   </navigation-rule>

> In this example, click button in inputname.jsp can change page to
> greeting.jsp, but the url in IE has no change, means it is as same
> "inputname.jsp", click link in greeting.jsp to goodbye.jsp, url in IE
> is "greeting.jsp"
> Seams it is always one step after current page. it works fine by click
> link. but if I refresh current page, it displayed previous page not
> current page.
> This can be solved by add <redirect/> in each navigation-case. But why
> default action has such problem? What is the purpose?


> --

> Anthony Hong


-- 
Best regards,
Iryna    
                        
mailto:istetska@lohika.com
ICQ #: 150867790


Re: JSF navigation url problem

Posted by Mike Kienenberger <mk...@gmail.com>.
On 3/2/06, Anthony Hong <an...@gmail.com> wrote:
> In this example, click button in inputname.jsp can change page to
> greeting.jsp, but the url in IE has no change, means it is as same
> "inputname.jsp", click link in greeting.jsp to goodbye.jsp, url in IE
> is "greeting.jsp"
> Seams it is always one step after current page. it works fine by click
> link. but if I refresh current page, it displayed previous page not
> current page.
> This can be solved by add <redirect/> in each navigation-case. But why
> default action has such problem? What is the purpose?

JSF is not a url-centric system.   The only url that matters is the
one that initially gets you to a page.   As you note, the only way to
"force" a new url to display is to use <redirect/>, which will cause
you to lose any t:saveState or messages data (because a redirect
causes two page requests).

The "why" is because any action taken on a page causes a post to the
same location, and the location is the same page name as the one you
came from as it's the only page capable of interpreting your action.  
A redirect causes a second page request to occur which can "fix" your
url if that's something you care about.   However, that's not normally
a concern.   Other related frameworks (like WebObjects, for instance)
don't even bother to make the urls have meaning:

https://domain/cgi-bin/WebObjects/Application.woa/1/wo/S5q791dgut93QDw3lS1ut0/1.1.25

I think JSF probably could have saved some confusion by doing the same
thing so people didn't think the urls displayed in the browser are
relevent to the response rendered.

I have also set up similar systems under Struts when I've implemented
a StateManager to handle back button requests.  For instance, here's a
Struts URL :)

https://domain/application/kqTDWXI4OgKkieWEnFIh1wcv1ZjQnbN85hU_1.5.psc

"Meaningful" URLs are only useful when they can be reused.   If your
JSF application is in such a state that it can reuse the URL (ie, no
previous state or messages saved), then all you need to do is throw in
a <redirect/> to formally specify that, and the URL will be
"meaningful" in the browser.