Previous Topic: Add Fields to Collector Pages

Next Topic: Localize Registration Services

Example: Collecting the Drink Attribute

The following example describes the steps taken to collect users’ favorite drinks and add that information to their profiles:

  1. Add an additional value to the user object class attribute in the object properties file, user.properties.

    The modified object class attribute is:

    OBJECTCLASS=objectclass,top,person,organizationalperson,inetorgperson,newpilotperson

    newpilotperson is an object class that is provided with iPlanet Directory Server. One of the attributes contained in this object class is drink, which is used to store a user’s favorite beverage.

  2. Add the drink attribute to the appropriate properties files, as described in the following table:

Properties File

Entry

user.properties object properties file

DRINK_ID=drink

user.properties presentation properties file

DRINK_ID=Admin:R,OrgAdmin:R

dms_en_US.properties locale properties file

DRINK_ID=Favorite Drink

  1. Create a new field in profile_user.jsp:
    <%
    bVisible = accessProperties.getVisible(role, "DRINK_ID");
    if (bVisible==true) { %>
    <tr>
        <td align="left">
            &nbsp;&nbsp;&nbsp;&nbsp;
    <jsp:setProperty name="localebean" property="key"
    value="DRINK_ID" />
            <font size=-1 face="arial,helvetica" >
    <jsp:getProperty name="localebean" 
    property="label"/></font>
    &nbsp;
        </td>
     <tr>
    <td>
    <%
    String drinkValue = properties.getValue("DRINK_ID");
    if ( drinkValue != null ) {
    %>
    <td><input type="text" size="42" maxlength="40"
    name="DRINK_ID" value= "<%= drinkValue %>">
    </td>
    <% } else { %>
    <td><input type="text" size="42" maxlength="40"
    name="DRINK_ID">
    </td>
    <% } %>
    <td><input type="hidden" size="42" maxlength="40"
    name="INFO_DRINK_ID">
    </td>
    </tr>
    <% } %>
    
  2. Add the attribute to the newuserjs.jsp for the checkForEmptyValues method:
    <%
        // Collect all attributes that will be checked for empty values
        Vector listOfIds = new Vector();
        /**
        listOfIds.add("PASSWORD_ID"); //never remove password!!
        **/
        listOfIds.add("DRINK_ID");
    

The rendered HTML form resembles the following: