Buttons and Links
f:param name="username" value="sarthak"
/h:commandLink
h:button and h:link:
f:param name="username" value="sarthak"
/h:link
h:graphicImage library="images" name="sofa.png"
/h:link
h:outputLink:
- The primary components for navigating within a JSF application
- These tags must be within the scope of an h:form tag to have their values communicated to the server.
- When a button or link is activated, a POST request sends the form data back to the server
- For Example:
- h:commandButton
- h:commandLink
- h:button
- h:link
- h:outputLink
- The primary components for navigating within a JSF application
- h:commandButton renders as a button; h:commandLink is a link;
- When a button or link is activated, a POST request sends the form data back to the server
- The “h:commandLink” tag is released since JSF 1.x, which generates a link act like a submit button when clicked.
- The “value” attribute is rendered as the anchor text, the “action” attribute is determined the target URL of the HTML “href” attribute.
- Example of h:commandButton
- Submit button
- Reset button
- Normal button
- Normal button with onclick event
- Example of h:commandLink
- commandLink
- commandLink + action
- commandLink + action + parameter
f:param name="username" value="sarthak"
/h:commandLink
h:button and h:link:
- Like h:commandButton and h:commandLink, but when a button or link is activated, a bookmarkable GET request sends the form data back to the server
- The “h:button” is a new tag in JSF 2.0, you can declared the navigation outcome directly in the “outcome” attribute, no need to call a bean to return an outcome like “h:commandButton” above.
- The “h:link” tag is a new tag in JSF 2.0, the “value” attribute is rendered as the anchor text, “outcome” attribute is determined the target URL of the HTML “href” attribute.
- Example of h:button
- Normal button without outcome
- Normal button with an outcome
- Normal button with JavaScript.
- Example of h:link
- link + “outcome”
- link + “outcome” + parammeter
f:param name="username" value="sarthak"
/h:link
- link + “outcome” + image
h:graphicImage library="images" name="sofa.png"
/h:link
h:outputLink:
- Generates an HTML anchor element that takes the user to a resource outside the JSF framework.
- The “h:outputLink” tag is released in JSF 1.x, the body of the tag is rendered as the anchor text, “value” attribute is rendered as the value of the HTML “href” attribute directly.
- Example of h:outputLink
- outputLink
- outputLink + “value”
Tags:
Java