Creating Java Managed Code 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\img00035.gif on the toolbar, or
Note: For the image\img00036.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\img00037.gif and select Managed Client Object

The Managed Client Object wizard appears.

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\img00038.gif

Figure 21: Managed Client Object (MCO) wizard

MCO ID: Nexaweb Studio automatically specifies the ID for the Java MCO as javaMCO. Specify a unique ID for this MCO by editing the provided ID or creating your own.

Source Folder: Nexaweb Studio stores Java MCOs in the project\src-client directory by default.

Package: Optionally, specify a package to contain the class.

Name: Nexaweb Studio automatically specifies the file name for a new Java MCO as JavaMCO incremented by 1 for each MCO created for a Nexaweb Java project. Specify a unique file name for this MCO by editing the provided ID or creating your own.

Superclass: Nexaweb Studio specifies the com.Nexaweb.client.mco.AbstractMCO class by default. Click Browse and enter the class name in the Choose a type field to select another class.

Interfaces: Click Add to specify an interface that this class implements.

 Click Next.
The
Method Settings wizard appears.

3. Complete the Method Settings wizard as follows:

image\img00039.gif

Figure 22. 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 23 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\img00040.gif

Figure 23: Auto Generated MCO and Event Code

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