You can change the target attribute of a JSF link from
a pageHandler. For example, you can set the link's target attribute
to _blank to make that link open in a new browser window.
This task has the following prerequisites. For more information, see
Accessing
a JSF component from a pageHandler.
- Your EGL Web project must have support for the JSF component interface.
See Adding JSF component interface support to an EGL Web project.
- The Faces JSP's page code file must have the following import statement:
import com.ibm.egl.jsf.*
- You must declare a variable of type UIViewRoot within the pageHandler.
- You must specify the name of the of the UIViewRoot variable in the pageHandler
property viewRootVar.
Follow these steps to change the
target attribute of a
JSF link from a pageHandler:
- On a blank line inside a function in the pageHandler, press Ctrl+Shift+Z.
The EGL Source Assistant window opens, displaying the JSF components on the
page.
- In the EGL Source Assistant window, select the JSF component you want
to access.
- Click OK.
The EGL source assistant adds two lines
of EGL code to the pageHandler. The first line defines an EGL variable of
the type that matches the JSF link that you selected. The second line associates
that variable with the JSF link. For example, the code might look like this:
linkEx1 HtmlOutputLink;
linkEx1 = myViewRoot.findComponent("form1:linkEx1");
- Using the EGL variable created by the source assistant, change the target
of the link with the setTarget() function. For example, to
make the link open in a new window, add this code:
linkEx1.setTarget("_blank");