package jsfhandlers;
import com.ibm.egl.jsf.*;
handler myPage type JSFHandler
{view = "myPage.jsp",
viewRootVar = myViewRoot}
myViewRoot UIViewRoot;
myInputVar string = "Hello";
function changeColor()
myInputField HtmlInputText;
myInputField = myViewRoot.findComponent("form1:text1");
myInputField.setStyle("color : red");
end
end
This example assumes an input control on the JSP named text1 that
is bound to the myInputVar variable and a command
button on the JSP that is bound to the changeColor function.import com.ibm.egl.jsf.*
The packages that are imported by this statement contain a group of ExternalType parts which provide access to Java code in the JSF controls. You do not need to edit these parts.
myViewRoot UIViewRoot;
handler myPage type JSFHandler
{view = "myPage.jsp",
viewRootVar = myViewRoot}
myInputField HtmlInputText;
myInputField = myViewRoot.findComponent("form1:text1");
myInputField.setStyle("color : red");
<input id="form1:text1" type="text" name="form1:text1" style="color : red" />
The related topics in this section give some other examples of operations that you can perform on JSF controls in this way. To see the full list of operations you can call on a given control, refer to the functions of the ExternalType parts in the com.ibm.egl.jsf package.
For example, the setWidth function sets the width of a control in pixels, or in a percentage of its original size if the percent (%) symbol is appended. Because this parameter is a measurement, it might seem to take a numeric data type as a parameter. However, this function must receive a string. To set the width of a control to 300 pixels, you must pass a string variable with the value "300".
myStyleString string;
myStyleString = myComponent.getStyle() + "; color: red; font-weight: bold";
myComponent.setStyle(myStyleString);
There are many different changes that you can make to JSF controls. See the related tasks for some examples.