Creating Java Managed Client Objects (MCOs)

Create a MCO to use a simple Java class that the client loads dynamically from the server to handle client events.

To create a MCO for your application, follow these steps:

1. Start the Managed Client Object wizard, either:
- Click image\img00266.gif on the toolbar, or
Note: For the image\img00267.gif icon to appear on the Studio toolbar, you must add the Nexaweb Element Creation toolbar, see Nexaweb Studio Toolbars.

- Select File > New > Managed Client Object, or

- Click
image\img00268.gif and select Managed Client Object

The Managed Client Object wizard appears similar to Figure 17.

2. Complete the Managed Client Object wizard as follows:

Note: Unless you can control the versions of your clients' Java Virtual Machines, all MCO code should be Java 1.1 compliant to ensure that your MCO will run in virtually any browser's JVM. However, if you do have control over your client JVMs and they are Java 1.2 compliant, you may use the Java 1.2 API's as desired.

 

image\img00269.gif

Figure 17. New Managed Client Object.

Source Folder: The location of the MCO class. Defaults to [ApplicationName]/src-client.

Package/Enclosing Type: Specify either the package or enclosing type to contain this java class. Recommended, but not required. To add a new package to this application, select New > Other > Java > Package.

Name: The name of the MCO. Nexaweb Studio derives both the filename and classname from this field.

Modifiers: Specify one or more of the following access modifiers:

  • public

  • default

  • private (enclosing type only)

  • protected (enclosing type only)

  • abstract (contains unimplemented methods and cannot be instantiated)

  • final (cannot be subclassed)

  • static (enclosing type only)

Superclass: Optionally, specify a superclass for this MCO.

Interfaces: Click Add to select interfaces that this class implements.

Which methods stubs . . .?: Select the methods stubs to create in this class:

  • public static void main(String [] args) - adds a main method stub to the new class.

  • Constructors from superclass -
    c
    opies the constructors from the new class's superclass and adds these stubs to the new class.

  • Inherited abstract methods -
    Adds to the new class stubs of any abstract methods from superclasses or methods of interfaces that need to be implemented.

Do you want to add comments . . .?: Select this for the wizard to add comments to the new class where appropriate.

 Click Next.
The
Method Settings wizard appears.

3. Complete the Method Settings wizard as follows:

image\img00270.gif

Figure 18. Method Settings

Events: Lists all Nexaweb component events by component or container type. Expand a component or container type to see all events for it. Select the Nexaweb component event for which to create code.

Method name: The name of the Nexaweb component event that you selected appears here.

The settings in this dialog create a method named onCommand with the necessary calls to obtain all information about the event. Figure 19 shows the code generated by the Nexaweb Event wizard.

4. Click Finish. Nexaweb Studio creates a .java file for this MCO in [workspace]/[ApplicationName]/source/client/[package] or as specified by the previous dialog [workspace]/NewApplication/source/client/example/TestMco.java. Nexaweb Studio displays a dialog prompting you open this file now.

5. Click Yes to open the file now, or No if you do not want to view the file now.

 

image\img00271.gif

Figure 19: Auto Generated MCO and Event Code

To assign this MCO to a component, see Connecting Business Logic to the User Interface.