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 for WebLogic

If you haven't started Workshop for WebLogic yet, use these steps to do so.

... on Microsoft Windows

If you are using a Windows operating system, follow these instructions.

...on Linux

If you are using a Linux operating system, follow these instructions.

To Create a Workspace

You use a workspace to contain related source code. This one will end up containing both your control source and the source you'll test the control with.

  1. If the Workshop Launcher dialog is not displayed, select File > Switch Workspace. Otherwise, skip to the next step.
  2. In the Workspace Launcher dialog, click Browse, then browse to the directory that you want to contain your new workspace directory.

    This can be any directory. You'll be creating a new directory inside this one for your workspace.

  3. When you have a directory selected, click Make New Folder. Name the new folder JUnitTutorial press Enter to create the folder, then click OK.
  4. In the Workspace Launcher, click OK.
  5. Close the Welcome view.


Workshop for WebLogic will create a new empty workspace in the folder you created, then refresh to display the workspace. Note that the Navigator view is empty.

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 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;
    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

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

Related Topics

Testing Controls

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


Skip navigation bar   Back to Top