• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

doubt with h: commandButton (URL no refresh =S)

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
According to this example here, in a commandButton can put this:

<h:commandButton action="/shopping/page2" value="Submit" />

I'm working that way in my application. The problem I have is that the url does not refresh in the browser

For example: In page1.xhtml I have commandButton with action="/pages/page1.xhtml"

This button should take me to a page named page1.xhtml. But it does not, the view is updated but the URL of the browser still has the same url above.

Ie in the browser says /page/page1.xhtml but in reality I'm on page 2

This brings me to future problems, as sometimes the browser gets stuck and does not know which page to send

Help please

 
Saloon Keeper
Posts: 27762
196
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
JSF URLs are not used the same way as most other webapp frameworks use them. They are more like session handles than absolute resource locators, which is why a postback operation doesn't return with the new page's direct-access URL in the browser toolbar.

The mechanism works just fine as long as you realize that a direct URL and a 'session handle' URL are not the same thing and you don't set up brute-force hyperlinks and expect that they'll contain the JSF session information (which is NOT the same thing as HttpSession!). A Session handle only works when submitted via POST, not GET, since the postback includes the JSF session information as part of the POST data stream.

You can forcibly update the displayed URL in the toolbar using the <redirect/> navigation option, but there is extra overhead when you do that.
 
Ranch Hand
Posts: 90
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Cesar

Tim's explanation is excellent, if you need to refresh the address you must you redirection, it's slow, however the redirection gives the browser a chance to update it's adress field.
Here I give you a examples of how to use redirection
In the <h:commandButton>

And if you're using navigation rules you need to add the <redirect/> in the section <navigation-case> of your faces-config.xml file, for example

Regards
Cesar
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cesar,
Doesn't using <redirect/> tag create an extra call to server side? Isn't this affecting the performance?
 
Cesar Loachamin
Ranch Hand
Posts: 90
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Amar

You're right the redirect option causes the client browser to make a new HTTP request for the specified view as opposed to just rendering the response without requiring a separate HTTP request. Regarding the performance, using a redirect will terminate the current request and cause a new request - response cycle to occur. If the page has a very large set of components, this could have a noticeable performance impact. Redirects can also necessitate an extra round trip to reinstantiate any request-scoped objects that have disappeared by the next request.

Regards
Cesar
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic