To use the service, you will create a web page in the client
to retrieve input, pass that input to the service, and display the
output from the service. You will start by creating a JSF Handler,
a type of EGL logic part that controls a web page, and then EGL will
create a web page to go along with this JSF Handler.
- In the Project Explorer view, click the EGLClient project
to select it.
- Click .
- Expand EGL and click JSF
Handler.
- Click Next.
- In the New EGL JSF Handler window, make sure that the Source
folder field is set to the project's EGLSource folder:
EGLClient\EGLSource
- In the Package field, type this
name:
jsfhandlers
- In the EGL source file name field,
type this name:
ClientPage
The window looks like this:
- Click Finish. The
new JSF Handler opens in the editor.
Don't save the file until these
instructions tell you to do so. When you save a JSF Handler, EGL checks
to see if the web page referred to in the view property
exists or not. If not, EGL creates the file and adds fields automatically
based on the variables in the JSF Handler and the DisplayUse properties
of those variables. If you save the file before you've added all the
variables, the new web page will not include all of the variables.
If this happens, you can delete the JSP file (not the JSF Handler
file) and generate the JSF Handler again to get a new web page.
- Remove the sample code from the new JSF Handler so that
the following is all that is left:
package jsfhandlers;
handler ClientPage type JSFHandler
{view = "jspLocation/jspName.jsp"}
end
- Set the value of the view property
to ClientPage.jsp, as in this example:
{view = "ClientPage.jsp"}
- Within the JSF Handler, create the following variables:
name string {DisplayUse = input};
city string {DisplayUse = input};
output string {DisplayUse = output};
- Below the variables, add this function:
function getHello()
end
You will add code to this function later. The JSF Handler looks like this:
- Save the file. When you save the file,
EGL creates a web page from the file automatically. This file is named
with the value of the view property, ClientPage.jsp,
and the file is placed in the WebContent folder of your project.
If
you did not get a JSP file, EGL is not configured to generate JSF
Handler parts automatically. Generate the JSF Handler manually by
right-clicking it either in the Project Explorer view or in the EGL
editor and then clicking
Generate. Then, follow
these additional steps to set up automatic generation of JSF Handlers:
- Click .
- In the Preferences window, click EGL and
ensure that EGL support with JSF and EGL
support with JSF Component Interfaces are selected.
- Expand EGL and click Generation.
- On the Generation page, select the Java check
box.
- Click OK.
Now JSF Handlers will generate automatically when you
save them.
- Open the ClientPage.jsp file in the editor. This
page has fields on it based on the variables you created in the JSF
Handler. These fields are pre-bound to the variables. This way, when
the values of these fields change on the page, the variables will
change to match. Similarly, when the values of the variables in the
JSF Handler change, the values of the fields on the page will change
to match.
This page also has several error message fields. This
does not mean that your page has errors; these fields will show errors
on the page if there are any when you run it.
- Locate the Page Data view. If you cannot find this view,
click . This view shows the
data available to your page, including the variables you created in
the JSF Handler. It also shows functions in the JSF Handler.
- In the Page Data view, expand and
find the getHello() function.
- Drag the getHello() function from the Page Data view directly
onto the bottom of the page. A button bound to the
function appears on the page. When the user presses the button on
the page at run time, the function in the JSF Handler will run.
- Save the page.
The page looks like this:
You
now have a web page ready to use the web service. In the next lesson
you will set up the project to act as a client for the service through
this web page.