> developer > dnu > courses > portal overview page 39
Novell Portal Services Overview and Gadget Development
April 2003
DeveloperNet University Course
Reader Rating    from ratings rate this article
View an eBook Version of this course - LARGE FILE! Send this page to a friend

Final Lab - Gadget Development Advanced: Development of a LDAP Browsing Gadget

The following is what should be accomplished in this lab:

  • Writing a complete gadget (almost!)

  • Considering the XML output from the gadget.

  • Writing a main.xsl file to render the XML to HTML.

  • Learn about the user interaction with the gadget through States.

  • Learn how to interact with the directory via the Authentication Manager.

  • Familiarize student with the NPS SKD documentation and API.

In this exercise you will use all the concepts and skills acquired during the course to complete a partially written gadget. This gadget will provide some simple browsing capabilities for the directory allowing the user to browse the objects in the tree and examine the attributes and their values for each object. Although the gadget is quite crude, by the end of the exercise you should have a better understanding of the processes involved in gadget development. Figures 54 and 55 demonstrate what your final gadget should look like.

Browsing the o=novell Context.

Figure 54: Browsing the o=novell Context.

Browsing the Admin user.

Figure 55: Browsing the Admin user.

Completing the Gadget

The data that will output to the browser and how this data is represented with XML.

  • How to render the above XML into HTML to be displayed by the browser via the main.xsl stylesheet.

  • The interaction the user has with the gadget how to capture and act on these user events in the Java code.

Testing the Gadget

Remember:

  • The gadget needs interaction with the directory so running with Gadget Runner will not work - use the actual portal instead.

  • When you have written enough code, package it all up and install the gadget into the portal. Then make subsequent changes to the relevant files incrementally.

  • Use the com.novell.nps.debug.Debug utility to help understand what's going on.

Getting Started

To get you going you will need to download the gadget.zip file. This .zip file contains the following files:

  • gadget.css - a Cascading Stylesheet to "prettify" the output.

  • /images/ - some GIF images to "prettify" the output.

  • LDAPBrowse.java - the skeleton Java code to complete.

  • main.xsl - the skeleton XSL code to complete.

XML Output Help

Below are some sample XML output the gadget might output, notice the currentDN and parentDN and state attributes and when no currentDN exists (i.e. we are at the root) the conventional up level indicator/symbol is present (ie. the ".."). Keep this XML output in mind when completing both the code and the XSL.

XML output while browsing the objects:


<LDAPBROWSE CURRENT_DN="" PARENT_DN="">
<LDAP_OBJECT>o=novell</LDAP_OBJECT>
<LDAP_OBJECT>cn=Security</LDAP_OBJECT>
</LDAPBROWSE>

<LDAPBROWSE CURRENT_DN="o=novell" PARENT_DN="">
<LDAP_OBJECT>..</LDAP_OBJECT>
<LDAP_OBJECT>ou=bracknell</LDAP_OBJECT>
<LDAP_OBJECT>ou=reading</LDAP_OBJECT>
<LDAP_OBJECT>cn=Admin</LDAP_OBJECT>
<LDAP_OBJECT>cn=Alison</LDAP_OBJECT>
</LDAPBROWSE>

XML output while browsing the attributes present on a given object:


<LDAPBROWSE CURRENT_DN="cn=Admin,o=novell" PARENT_DN="o=novell" state="AttrList">
<LDAP_ATTRIBUTE ATTRIBUTE_TYPE="String">
givenName
</LDAP_ATTRIBUTE>
<LDAP_ATTRIBUTE ATTRIBUTE_TYPE="String" NAME="sn">
<VALUE>Smith</VALUE>
</LDAP_ATTRIBUTE>
<LDAP_ATTRIBUTE ATTRIBUTE_TYPE="Multi-String" NAME="mail">
<VALUE>admin@novell.com</VALUE>
<VALUE>administrator@novell.com</VALUE>
</LDAP_ATTRIBUTE>
</LDAPBROWSE>

In the Java code you may wish to use the com.novell.nps.gadgetManager.XmlUtil convenience object (see the exteNd Director Gadget Developer Kit documentation at: http://www.developer.novell.com/ndk/downloadaz.htm).

The data is pulled from the directory via the com.novell.nps.authentication.AuthenticationManager object. This portion of the code has been provided, however be sure to examine it carefully to fully understand what functionality it provides.

So, go ahead and look at the LDAPBrowse.java code, from the gadget zip file and fill in the 10 TODOs. When you have completed the TODOs, check your answers with Solution-LDAPBrowse.java. If you would like to see the complete source code for LDAPBrowse.java, see LDAPBrowse_Solution.java in the downloads section.

Next, work on the main.xsl skeleton. When you have completed this, check your solutions with Solution-main.xsl.

Previous Contents Next
download sample file