See Also
A simple component displays one value. Examples of simple components include Button, Checkbox, Hyperlink,
Text Field, or Static Text. For easiest data binding, use components from the Basic category of the Palette.
After you add a web service to the IDE and to a page, you can call a web service method by using either of the following techniques:
- Bind a method to a component. You can use this technique to view the results of the web service method, but you cannot update it. You do not need to write any Java code.
- Call the web service method in your
Java code. You can use this technique to view or update the web service.
The examples in the following procedures describe how to call the same web service
method by using both techniques.
To bind a component to a method:
- If the web service is not part of the IDE,
add the web service to the IDE.
- Drag and drop the method onto the component.
- Right-click the component and choose Bind to Data.
- In the Bind to Data dialog box, click the Data Provider tab.
- Choose the method's data provider.
- Select the data field to display in the component.
For example, consider the following scenario. You want to use
the getPersons method of the TravelWS web service to
display the first person's name in a static text field.
- Add the TravelWS.wsdl file shipped with the IDE.
- Drag the Basic > Static Text component to the page.
- Drag the getPersons method onto the static text field.
- Right-click the static text and choose Bind to Data.
- Select name from the data field list.
To call a method in your Java code:
- If the web service is not part of the IDE,
add the web service to the IDE.
- If the web service has not been added to the page,
add the web service to the page.
- If desired, select a method to see its properties in the
Properties window.
- If desired, test the web service's methods by completing the following steps:
- Expand the web-service-name node.
- Right-click the method and choose Test Method.
- Type a test value for the parameters and click Submit.
- View the results and click Close.
- Call the methods in your Java code.
For example, consider the following scenario. You want to
use the getPersons method of the TravelWS web service to
display the first person's name in a static text field.
- Add the TravelWS.wsdl file
shipped with the IDE.
- Drag TravelWS to the Visual Designer.
- Drag the Basic > Static Text component to the Visual Designer.
- Go to the Page1.java source code by selecting the Java tab.
- In the prerender() method, enter the following code.
try {
staticText1.setValue( travelWSClient1.getPersons()[0].getName() );
} catch (Exception e) {
log("Page1 Initialization Failure", e);
throw e instanceof FacesException ? (FacesException) e: new FacesException(e);
}
- See Also
- About Web Services
- Adding a Web Service to the IDE
- Binding a List Component to a Web Service Method
- Binding a Table Component to a Web Service Method
- About the Projects and Files Windows
- About the Java Editor