When you bind a JSF button to a function in the JSF Handler,
the function runs when the user clicks the button.
The easiest way to accept a command from a web page is to write
the function first and then bind it to the button:
- Create a web page in an EGL web project.
- In the page's JSF Handler, create a function. At this point, you
only need the basics of the function to do the binding; you can code
the logic for the function later.
- Save the JSF Handler.
- Open the associated JSP file.
- From the Enhanced Faces Components drawer
of the Palette view, drag a Button - Command onto
the page.
- In the Page Data view, expand JSF Handler.
The functions and variables in the JSF Handler are listed here.
- From the Page Data view, drag the function directly onto the button
that you added to the page.
The function is bound to the button.
Alternatively, you can code the function from the Quick Edit view
while working on the web page:
- Open the JSP file.
- From the Enhanced Faces Components drawer
of the Palette view, drag a Button - Command onto
the page.
- Right-click the button and then click Edit Events.
The Quick Edit view opens. Typically, this view is for JavaScript code, but you can use it to
write functions in the JSF Handler as well.
- In the Quick Edit view, click Command at
the left side of the view.
- Click on the right area of the Quick Edit view to set focus there.
The view shows a new EGL function that is actually in the JSF Handler.
- Type your EGL statements in the new function. You must at least
add a comment in the function in the Quick Edit view. If you do not
change the code in the function, the editor assumes that the function
is not needed and removes it.
Limitations
Command elements on the page
can be bound only to functions in the JSF Handler, not functions in
other logic parts such as libraries. Also, you can bind only functions
with no parameters. If the function needs input to run, create a variable
in the JSF Handler and bind it to an input control on the page. Then,
you can use that variable as a parameter in a function invocation.
Also,
see Binding a control on a web page to a variable for
a limitation having to do with the location of buttons and controls
within a <form> tag.