• 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
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

JSF 2 : what is all the buzz about the <h:link> and <h:button> ???

 
Ranch Hand
Posts: 50
jQuery Eclipse IDE Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi I'm new to jsf 2 (worked couple of years with jsf 1.2)

and I'm trying to figure out what so special about the <h:link> and <h:button> and what it is good for?

and regarding to bookmarkabilty that can be achieved with this two new tags... isnt the same thin can be achieved with "redirect" tag added to config xml of the jsf ?


thanks ahead...


Regards

Daniel Reznick...
 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess they aren't the same, In JSF 2.0 they are used as direct links they don't issue a post request and then a redirect, instead they issue a get request directly to the URL specified, so they don't have an action attribute. Besides they have more feature that didn't exist before e.g. Integrating with View Parameters.

You can find more information in whats-new-in-jsf-2
 
author
Posts: 82
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I also recommend Andy Schwartz's blog entry. Also, these two tags work very well with the new f:viewParam tag. I have substantial content in this starting on page 127 of the book.

Ed
 
blacksmith
Posts: 979
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is the entry Andy Schwartz

So if I understand correctly the new tag <h:link> is a simplification of what in Struts 1
would have been done more or less like:


Where you had to specify the whole url...
 
Author
Posts: 164
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
These new components are exciting mainly because they were sorely missed in earlier versions of JSF. At last, they are available. The reason they were missed is because regular hyperlinks happen to be the most common way to link pages (the other way being a form submission). So the thing that you had to do the most often was kind of difficult. Your only option was to use <h: outputLink>. But that component has no concept of view IDs, so the target would have to be a URL that included the servlet mapping (*.faces or /faces/*).

The <h:link> and <h:button> are also compelling because they can manage the query string for you when combined with view parameters. If you've ever created a search form like bugzilla (see https://javaserverfaces-spec-coderanch.dev.java.net/issues/), you would have had to itemize and propagate each individual request parameter that makes up the search anywhere you have links on the page. View parameters allow you to declare the request parameters on the target page (as view parameters) and those parameters will automatically be added to any links that target that view ID. So it turns out to be very convenient.
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well said, Dan!

Another benefit of the <h:link> and <h:button> tags is that they enforce the POST, Redirect, GET pattern, which provides a much more consistent, user-friendly experience that is safer from potential issues with duplicate form submissions the "back" button.
 
She's brilliant. She can see what can be and is not limited to what is. And she knows this tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic