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 JSF Handler part. This snippet has
the following prerequisites:
- The JSP page has a data table.
- The names of the JSP identifiers have not been changed from the
default.
- The page is defined as request in scope in faces-config.xml,
not session.
To insert and configure this snippet, follow these directions:
- In a JSF Handler, define a character or string variable to receive
the clicked value.
- Place the cursor on a blank line in the JSF Handler where it is
legal to add a function. (This snippet includes an entire EGL function.)
- In the EGL drawer of the Snippets view, double-click the Get
clicked row value snippet. The Insert Template window
opens. For more information, see Inserting EGL code snippets.
- In the Insert Template window, type the name of the variable as
the value of the receivingVar variable.
- Click Insert.
- From the Enhanced Faces Components drawer in the Palette view,
add a command hyperlink to a field in the data table.
- For the target of the command hyperlink, specify the name of the
JSP page. The hyperlink links to its own page.
- Add a parameter to the hyperlink and give that parameter the same
name as the variable in the JSF Handler that receives the clicked
value.
- On the All tab of the Properties view,
set the action property to the getVal() function.
The code that is inserted by this snippet 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