Retrieving the value of a clicked row in a data table

The getClickedRowValue snippet in the EGL drawer of the Snippets view is a function that retrieves the hyperlinked value of a clicked row in a data table. This snippet must be placed in an EGL PageHandler. This snippet has the following prerequisites:
  1. The JSP page has a data table.
  2. The names of the JSP identifiers have not been changed from the default.
  3. The page is defined as request in scope in faces-config.xml, not session.
To insert and configure this snippet, follow these directions:
  1. Insert the snippet's code into the PageHandler. For more information, see Inserting EGL code snippets.
  2. Define a char or string variable to receive the clicked value.
  3. Add a command hyperlink (from the Faces Components drawer in the Palette view) to a field in the data table.
  4. For the target of the command hyperlink, specify the name of the JSP page. The hyperlink links to its own page.
  5. Add a parameter to the hyperlink and give that parameter the same name as the variable in the PageHandler that receives the clicked value.
  6. Set the action property (located on the All tab of the Properties view) to the getVal() function.
The code inserted by this snippet is as follows:
function getVal()
	javaLib.store((objId)"context", 
   "javax.faces.context.FacesContext",
   "getCurrentInstance");
	javaLib.store((objId)"root", 
   (objId)"context", "getViewRoot");
	javaLib.store((objId)"parm", 
   (objId)"root", 
   "findComponent",
   "form1:table1:param1");
	recVar = javaLib.invoke((objId)"parm", 
                          "getValue");
end

Related tasks
Inserting code snippets into EGL and JSP files

Feedback
(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.