4.2 Creating a Property Book Page

Property book pages are helpful for viewing and modifying attributes of an object. Unless you specify otherwise, pages automatically appear in the Modify Object task when the object selected is of the type that the page is designed to modify. Pages can also be accessed in a role-based way similar to tasks.

To create a property book page, you need to:

Once you have created a property book page, test it by running the Modify Object task (requires the Ojbect Management plug-in) and select an object of the type your page can modify. Confirm that your page is available.

4.2.1 Create the Java Class

Create a Java class that handles the business logic of the page. The class should extend com.novell.emframe.dev.PropertyBookPage. Typically, you don’t need to create a custom Java class unless your page must deal with nonstandard syntaxes, such as octet strings.

NOTE:For pages that deal with eDirectory object attributes, use com.novell.emframe.dev.DirPropertyBookPage instead of creating your own class. This automatically uses the eDirectroy Access Service (EDAS) for reading and writing attributes to eDirectory.

To create a custom Java class:

  1. Create a class that extends DirPropertyBookPage.

  2. Override the show(TaskContext context, java.util.Properties resultStrings)method to get data from the target.

  3. Override cache(PropertyPageContext context) to cache data posted from the client.

  4. If you are not using NSObject in the cache method, override the commit(PropertyPageContext context) method to properly update back links and write changes to the data source through an API other than the NDSNamespace.

IMPORTANT:To get a reference to an NSObject (for eDirectory) from any of the above-mentioned methods (show, cache, commit), call one of the following, then read or write to the resulting NSObject:

  • this.m_nsobj

  • NSObject target = this.getDirPropertyBook().getNSObject()

When the user clicks Apply, it calls the NSObject’s update method.

The iManager SDK provides an example of extending DirPropertyBookPage in PropertyPageExampleTask1.java and PropertyPageExampleTask2.java, which are available in the SDK at SDK_HOME/samples/src/com/company/plugins/.

4.2.2 Create the JSP

To create the UI for a page, you create a JSP. The process is nearly the same as creating the UI for a task, except that for a page, you always create only one JSP. In a property book, related attributes are usually grouped together on a page. Create a JSP that displays the values of the attributes. Use form controls for attributes that you want to allow users to modify. Disable the controls when users don't have rights to modify the attributes.

To create a property book page JSP:

  1. Copy the PageTemplate.jsp file and save it as your new JSP (For example, myPage.jsp.)

    PageTemplate.jsp is in SDK_HOME\tomcat\webapps\nps\portal\modules\dev\dkins\default\devices\browser.

  2. Insert the necessary HTML controls after the comment <!-- REMIND: CONTENT GOES HERE -->.

  3. In the JavaScript isPageValid method, insert client-side validiation that tests the values in the controls and returns true if the values are valid.

For more information about creating JSPs, see Creating the UI and Tips for Creating JSPs.

4.2.3 Create the XML Registration File

Property book pages must be defined in an XML registration file. Store the registration file in a \plugins directory inside your module. For example, Identity Manager stores its property book registration files in tomcat\webapps\nps\portal\modules\dirxml\plugins.

The registration file uses <page> or <private-page> elements to organize tasks into pages. The <page> and <private-page> elements have identical structures. Use the <private-page> element to prevent the page from appearing as part of the Modify Object task; otherwise, use <page>.

For example:

 <page>
    <id>core.UserId</id>
    <version>1.0</version>
    <required-version>2.7.0</required-version>
    <class-name>com.novell.emframe.dev.DirPropertyBookPage</class-name>
       <merge-template>ModifyUser_Info</merge-template>
       <help-file>base/TestHelp.html</help-file>
 
       <default-display-name>Information</default-display-name>
       <display-name-key></display-name-key> 
       <resource-properties-file>com.novell.CoreTasksResourceBundle</ resource-properties-file>
 
       <chapter>
          <id>core.general</id>
               <display-name-key>GeneralChapterName</display-name-key> 
          <resource-properties-file >com.novell.ResourceBundle</resource-properties-file>
       </chapter>
 
       <object-type-name>User</object-type-name>
       <description></description> 
 
       <rights-assignment>        
          <attribute-name>Given Name</attribute-name>
          <privilege>Supervisor</privilege>
       </rights-assignment>        
       <rights-assignment>        
          <attribute-name>Surname</attribute-name>
          <privilege>Supervisor</privilege>
       </rights-assignment>        
 </page>
 

For complete descriptions of supported XML elements for the property book page registration file, see XML Schema for Installation and Registration Files.