Home | Ajax | BioInformatics | Dojo | EAI | EJB | Hibernate | J2ME | Java | Java Glossary | Java Servlets | JavaScript | Jboss | JDBC | JDO | Jmeter | JSF | JSP | JUnit | Maven | MySQL | Spring Framework | SQL | Struts | Technology | WAP | Web Services | XML


 
  
 
Programming Tutorials: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML
 

 
Facing Programming Problem?
Ask Questions?, Browse Latest Questions, Question-Answer Guidelines
JSF
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments

JSF commandLink Tag

                          

This section illustrates you about the JSF commandLink tag which is rendered as a anchor tag. And this tag behaves as a command button for the form submission and this tag is also used for the event handling purposes through the backing bean. This tag has text that can be labeled by some external resources like properties file from the message bundle.

Here, you will see more about the commandLink tag of JSF how is it used in JSF programming. There is a program with the complete code of JSF has been given for understanding the procedure of using the tag.

Code Description:

<%@ page contentType="text/html" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

<f:view>
<html>
     <head><title>jsf h:commandLink example</title></head>

     <body>
          <h:form>
                 <h:commandLink value="Go for list of examples." action="page2" />
          </h:form>
     </body>
</html>
</f:view>

Here, when your run the above program, output will be seen like the following image in which the text "Go for list of examples." is looking like a hypertext. This is not only a anchor tag. This link behaves like a command button. You can perform an action at the specific event.

Rendered Output:

When you run the above example, your JSF tags are converted in to HTML code that is given. Following html source code is for the above written JSF code.

HTML Source Code:

<html>
     <head><title>jsf h:commandLink example</title></head>

     <body>
          <form id="_id0" method="post" action="/h-tags/pages/commandLink/
commandLink.jsf" enctype="application/x-www-form-urlencoded">
               <a href="#" onclick="document.forms['_id0']['_id0:_idcl']
.value='_id0:_id1'; document.forms['_id0'].submit(); return false;">Go
 for list of examples.</a>
	       <input type="hidden" name="_id0" value="_id0" /><input
 type="hidden" name="_id0:_idcl" />
          </form>
    </body>
</html>

This JSF tag has some attributes these explained as follows:

  • accesskey: This attribute set the key for the component through which the component can be accessed. Specified key is also used for transferring focus from one component to the component where it mentioned in with the JSF commandLink tag.
  • action: This is also an attribute of the JSF commandLink tag. This attribute is used for handling events from the backing bean or any other resources to invoke the component when the component is activated by user. This type of action event is completed through a action method of the backing bean class. This method will either return a boolean value true or false by whom the Java Server Faces MVC Framework is designed. And navigations are depended on generated events and actions.
  • actionListener: This attribute sets a method-binding expression with a backing bean. This method handles events.
  • binding: This attribute binds values with backing bean.
  • charset: This attribute sets the character encoding for the document that linked to by the hyperlink.
  • coords: When you are using the link with a client-side image map, this attribute sets the position and the shape of spot on the screen.
  • dir: This attribute set the direction of the text. The value for the attribute is accepted as "LTR" (left to right) or "RTL" (right to left).
  • hreflang: This attribute sets the language code for the resource linked to by the hyperlink.
  • id: This attribute sets the name for the identification of the component. It's value will be unique in the closest naming container.
  • immediate: It's value is a boolean value that indicates for the component events that should be sent to registered event listeners immediately. The immediate attribute allows you to turn off validation for a particular component.
  • lang: It sets the code for the language to be used in the markup generated by this component.
  • onblur: This attribute sets JavaScript code when the component loses the focus.
  • ondblclick: This attribute sets the JavaScript code when the component has been double-clicked over the component.
  • onfocus: This attribute sets the JavaScript code when the component receives focus.
  • onkeydown: This attribute sets the JavaScript code when key is pressed down over the element.
  • onkeypress: This attribute sets the JavaScript code when key is pressed and released over the element or the component.
  • onkeyup: This attribute sets the JavaScript code when key is released over the element or component.
  • onmousedown: Specified JavaScript method is executed when mouse is pressed down over the component.
  • onmousemove: This attribute sets the JavaScript code to executed when the mouse pointer is moved within the component.
  • onmouseout: This attribute sets the JavaScript code to execute when the mouse pointer is moved away from the element.
  • onmouseover: This attribute sets the JavaScript code to execute when the mouse pointer is moved inside the element.
  • onmouseup: This attribute sets the JavaScript code to executed when the mouse pointer is released from the component.
  • rel: This attribute tells you about the relationship between the current document and the document linked to by the hyperlink. It's values are the list of the link types separated by space from each other.
  • rev: This attribute identifies a reserve link from the document linked to by the hyperlink to the current document. It's values are a list of link types separated by space from each other.
  • rendered: This attribute takes a boolean value that indicates for the rendering it or not in the view.
  • shape: This attribute sets the shape of the hotspot for viewing on the screen during the client side image mapping. It's some valid value is "rect" for the rectangular region, "default" for the entire region, "circle" for the circular region and "poly" for the polygonal region.
  • style: If you want ot add any CSS with the component then you can put the style as the value of the attribute. Added CSS will be applied on for the component.
  • styleClass: This attribute holds the CSS class name which is defined in the external style sheet.
  • tabindex: This attribute sets the tab index for the component. When you press the TAB key then the component will be focused after focusing all those components whose tab index is less than the component.
  • target: This attribute set the identification of a frame in which the resource has to be displayed that is linked to by the hyperlink.
  • title: This attribute holds a string value that is shown as a tool-tip text of a component or element.
  • type: This attribute tells the component type whether it is submit type or reset etc.
  • value: This attribute set the display value for the component. It will be directly or any other resources like the backing bean or a message bundle. You can manage the backing bean for the value of the component or element.

                          

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

1 comments so far (
post your own) View All Comments Latest 10 Comments:

I need to change the value of a f:param inside the h:commandlink from javascript.

I have a combo that everything it changes, the value of a param inside the commandlink must be update. Do you have any idea of how to do taht?

Thank

Julián

Posted by Julián on Thursday, 03.6.08 @ 05:08am | #51622

Latest Searches:
fileupload jsf
image on title bar
where to keep backgro
Murachà¹?à¸??à¹?à¸???à
how to open the excel
struts hello
Sorting user input num
Servlet demo tutorial
getting and setting co
student example in str
multi colors in jsp
images from mysql data
java write line
point to the start of
add a search box in a
storing a file into my
create pdfs
java coding question:
Borders
performing operations
infix
xforms
average numbers
Jaa
examples on servlets
pagination in jsp usin
delete data in mysql d
buble sort
grid
struts2 gwt
property editor in jav
ajax examples java
Javascript Menus Image
virtual functions in j
using next and previou
javabean\
dynamic array value
stored procedures
program in java which
tilesdef
Ajx
droping column in tabl
java button event fram
delete
how to break a table d
insert fields blob
file uploading code us
log4j filter
<s:autocompleter> ajax
clear values from a fo
finding the square of
low level design
viva qus. and ans. of
how to pass same varia
Combo Box operation in
swing
javascript history bac
char get consonan
Create Expand Bar in S
project
pdf using xsl
java coding question:
Insert Data into Datab
richtext format in ht
jsp combo box my sql
Check Properties
charts using POI
get
Visual Basic Networkin
handle connect databas
oracle driver class
struts program for mye
treemap with comparabl
java form generator
struts html:select
delete column
JMeter Json
Java Notes: Downcastin
Eclipse 3.4 EJB
import class in servle
Java String toLowerCase Example
Java String toCharArray Example
Java String substring Example
Java String indexOf Example
Java String startsWith Example
Java String hashCode Example
Java String matches Example
Java String length Example
Java String lastIndexOf Example
Java String isEmpty Example
Java String equalsIgnoreCase Example
Java String equals Example
Java String endsWith Example
Java String copyValueOf Example
Java String contentEquals Example
  EAI Articles
  Java Certification
Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.