This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Journey To Enterprise Agility and have Daryl Kulak & Hong Li on-line!
See this thread for details.
Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

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

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • 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

 
Bartender
Posts: 19664
92
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • 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
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • 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
  • 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
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!