You can change the size of a JSF image on a Faces JSP page with EGL code.
You must use a Faces image component; ordinary HTML image tags can not be
changed directly from an EGL pageHandler.
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 size of a JSF image component from an
EGL 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 image 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 component that you selected. The second line
associates that variable with the JSF component. For example, the code to
access a JSF image component might look like this:
imageEx1 HtmlGraphicImageEx;
imageEx1 = myViewRoot.findComponent("imageEx1");
- Using the EGL variable created by the source assistant, change the size
of the JSF image component with the setHeight and setWidth functions,
passing each function a string or literal that specifies the measurement in
pixels. For example, to make the image 300 pixels wide and 200 pixels tall,
add this code:
imageEx1.setWidth("300");
imageEx1.setHeight("300");