How Do I: Create and Use a Custom Java Control Within an Existing Project?

Java controls that you create can provide a convenient place to store complex logic while providing a simple interface for application developers. This topic describes how you can create a new control for use in an existing application.

For a step-by-step introduction to creating Java controls, see Tutorial: Java Control.

To Create a New Custom Java Control in an Existing Project

  1. In the Application tab, locate the project in which you want to use the new control.
  2. (Optional.) Create a new folder in this project to contain your control's source code.

    It is not necessary to create a new folder, but you may find that it is a convenient way to keep your control souce files separate from the rest of your application's code. For example, if you were writing an application that handled internal purchasing, you might put controls that handle tax processing in a taxLogic subfolder of your project.

  3. Right-click the folder that will contain your control code, then choose New-->Java Control.
  4. In the New File dialog, in the left-hand pane, click Common.
  5. In the right-hand pane, click Java Control.
  6. In the File name box, type a name for your new Java control.

    Note that you can simply begin typing — WebLogic Workshop will preserve the file extension.

  7. Click Create.

    You can now add functionality to the control. For more information, see How Do I: Begin a New Custom Java Control?.

To Use a Custom Java Control from Within a Project

  1. Open the file from which you will use the Java control.

    For example, if you want to call the control's methods from a web service, open the JWS file in Design View. You can also use your Java control from within a Java page flow or JavaServer Pages file.

  2. Locate your control's JCS file, drag it onto Design View and drop it there.

    The result of adding the control will be different, depending on whether you're using it from a web service (JWS), JavaServer Pages file (JSP), or page flow (JPF). The control you added should be visible in the Data Palette.

Samples

The SamplesApp application installed with WebLogic Workshop provides several sample custom Java controls. Look for these in the WebServices project, in the localControls subfolder.

Related Topics

Tutorial: Java Control