5.2 Creating a Custom Plug-In

To create a plug-in using the Plug-In Studio:

  1. Launch iManager and open the Configure view.

  2. Select Role Based Services > Plug-In Studio.

  3. In the Installed Custom Plug-ins page, click New.

    To create a task or property book page based on an existing one, select the existing task or page, then click Actions > Copy.

  4. In the Choose Object Type and Platform page, provide the required information, then click Next.

    Available Classes: Select the type of object that you want to manage with your plug-in. The list shows the classes that are available in the tree to which you are currently connected.

    Target Device: Select the device type that your plug-in will target. Default is appropriate for most situations where users access the plug-in with a Web browser. Select Browser to target Web browsers that require a simplified layout.

    Plug-in Type: Select the type of plug-in you want to create. You can select a property book page or a task that either creates, modifies, or deletes objects of the selected class.

    Add Aux Classes: Select to make auxiliary classes available in the Plug-In Studio. When selected, you can specify the auxiliary classes that you want to use. To select multiple classes, <Ctrl>-click.

  5. In the Plug-in Studio page, complete the custom plug-in configuration.

    The Plug-In Studio consists of four main areas:

    Attributes: Provides a list of attributes the plug-in can modify. Double-click an attribute to add it as a field in your plug-in. Each attribute has If you are creating a Create task, the Plug-In Studio automatically adds fields for mandatory attributes.

    Controls: Displays the controls that are available for the selected attribute.

    Plug-in Fields: Displays the currently selected attribute controls for your plug-in. Click-and-drag a control to change its position within the plug-in. Plug-in Studio provides three buttons with each control so you can customize your plug-in as needed:

    • View or Modify Parameters: Lets you configure the control’s properties to specify if it is read-only, mandatory, etc.

    • Change Control: Lets you change an attribute’s control type from the attribute’s list of available controls.

    • Delete: Removes the attribute control from the plug-in.

    Plug-in Properties: Specifies the properties of your custom plug-in, including the following:

    • Plug-in ID: Specifies a unique name for the plug-in. By default, this is the plug-ins Display Name as well (in the Advanced Properties dialog box.) You can make the Display Name of a task or page identical to that of an existing task or page by modifying the XML registration file to use a display name from a resource bundle. For example: <display-name-key>MyTaskDisplayName</display-name-key>.

    • RBS Collection: Specifies the RBS Collection into which the custom plug-in is installed.

    • Role: Specifies the RBS role with which the custom plug-in is associated.

    • Advanced: Lets you specify additional plug-in settings, including control labels and multi-object editing.

    • Chapter: (Conditional) Specifies the chapter for a property book page.

    • Object Type: (Conditional) Specifies the types of objects a property book page can modify.

  6. Select Preview to test your plug-in.

    When you have added fields and set the properties for your plug-in, you can test it by clicking Preview. iManager displays a new browser window showing your plug-in as it will appear to the user. Click Cancel to close the preview window.

    WARNING:Changes you make to an object using the preview of your plug-in are saved to the directory. If you need to test the plug-in beyond verifying the layout and testing the operation of the controls, you should use the Plug-In Studio in a non-production environment.

  7. Select Install to install the plug-in.

    If you have specified all required properties and parameters, your custom plug-in is installed into the directory and saved in /tomcat/webapps/nps/packages/custom.npm.

5.2.1 Adding Drop Down List Values Dynamically

Custom plug-ins, including those developed with Plug-in Studio, support dynamic creation of drop down list options. The following example shows one way to accomplish this.

In your task, include Java code such as the following:

 properties.put("Sch_ClassList.count" , size);
 
 for (int i=0; i<size; i++)
 
    {
 
       properties.put("Sch_ClassList.name." + i, str[0]);
 
    }
 

Then, in plug-in's JSP file, display the dynamic dropdown list as follows:

 <td>
 
 <select name="AvailableClasses" size=10 style="WIDTH: 340px" >
 
    <% c.set("i", "0");
 
    while (c.lt(c.var("i"), c.var("Sch_ClassList.count")))
 
    { %>
 
       <option value="<%= c.var("Sch_ClassList.name."+c.var("i")) %>
 
       <% c.inc("i");
 
    } %>
 
 </select>
 
 </td>
 

Dynamic drop down lists are also supported by MVSelectBox. In HTML, the MVSelectBox control is rendered as a drop-down list using the select tag. Options are specified using the option tag. To dynamically add options, modify the JSP created by the Plug-In Studio and use JSP scriptlets or tag library actions to create options at runtime. The following example shows how an MVSelectBox control designed to modify the employeeType attribute can be modified to add an additional option if the user has a certain given name:

 <SELECT name="_employeeType" style="width:<iman:string key="UI.textboxPixel"/>" onChange="onMVSelectChange(’employeeType’, this)">
 
    <OPTION value="Individual Contributor" <x:if select="count($edasXml/edas/employeeType/value[text()=’Individual Contributor’])">selected</x:if>>Individual Contributor
 
    <OPTION value="Manager" <x:if select="count($edasXml/edas/employeeType/value[text()=’Manager’])">selected</x:if>>Manager
 
    <x:if select="count($edasXml/edas/Given_Name/value[text()=’Jack’])">   <OPTION value="CEO" <x:if select="count($edasXml/edas/employeeType/value[text()=’CEO’])">selected</x:if>>CEO
 
    </x:if>
 
 </SELECT>
 

The Plug-In Studio creates JSPs in webapps/nps/portal/modules/custom/skins/default/devices/default.