Previous Next vertical dots separating previous/next from contents/index/pdf

Step 1: Create a Custom Control

In this step you will create a Utility project to house your control so they can be used by multiple modules in an application.

In this step, you will:

To Start Workshop

If you haven't started Workshop yet, follow these steps: Start Workshop.

To Create a New Workspace (Optional)

If you would like to execute the tutorial in a separate workspace follow these steps: Create a New Workspace.

Note: If you already have a workspace open, this will restart Workshop. Before beginning, you might want to launch help in standalone mode to avoid an interruption the restart could cause, then locate this topic in the new browser. See Using Help in a Standalone Mode for more information.

For Workshop Studio and Workshop for JSP Users Only: Install WebLogic Server

If you are using Workshop for WebLogic, skip this step and go directly to the next step.

If you are a Workshop Studio or Workshop for JSP user, follow these instructions in install the WebLogic Server domain for Workshop:

This server domain contains runtime libraries required by the tutorial application.

To Create an Utility Project

An utility project contains shared code that can be used across multiple different projects.

  1. Click File > New > Project.
  2. In the New Project dialog, expand J2EE, select Utility Project, then click Next.
  3. In the New Java Utility Module dialog, in the Project name field, enter MySharedControls, then click Next.
  4. Under Select Project Facets, confirm that the "Beehive Contols" facet is selected. (This facet must be selected because it contains ControlTestCase, an extension of junit.framework.TestCase, as well as the control validation and build libraries.)

    Click Finish.

To Create a Custom Control

In this step you will create the control to be tested.

  1. On the Project Explorer view, expand the node MySharedControls, right-click the src folder and select New > Package.
  2. In the New Java Package dialog, in the Name field, enter sharedcontrols, and click Finish.
  3. On the Project Explorer view, right-click the sharedcontrols package and select New > Custom Control.
  4. In the New Control dialog, in the Control name field, enter EmployeeControl and click Finish.
  5. On the Project Explorer view, open the package sharedcontrols and double-click EmployeeControlImpl.java to open the file's source code. Edit the source code so it appears as follows. Code to add appears in red.
    package sharedcontrols;
      
    import org.apache.beehive.controls.api.bean.ControlImplementation;
    import java.io.Serializable;
     
    @ControlImplementation
    public class EmployeeControlImpl implements EmployeeControl, Serializable {
        private static final long serialVersionUID = 1L;
     
        public String[] getManagerNames() {
            return new String[]{"Jane","Bob","Amy"};
        }
    }
  6. Place the cursor inside the method name getManagerNames and press Ctrl+1.
    This will bring up an options menu.
    Double-click the option Create in super type 'EmployeeControl'.
    This will add the method signature to the control interface file EmployeeControl.java.

  7. Press Ctrl+Shift+S to save your work.

Related Topics

Testing Controls

Click one of the following arrows to navigate through the tutorial:


Still need help? Post a question on the Workshop newsgroup.

 

Skip navigation bar   Back to Top