Policy Server Guides › Policy Design Guide › Customizing Registration Services › Collect Additional Attributes › Add Fields to Collector Pages
Add Fields to Collector Pages
Registration Services uses collector pages to enable users to add or modify a user’s profile. The collector page references a profile page, which defines the presentation of user profiles by specifying the form elements, such as text fields and list boxes, that are displayed in the collector pages.
To collect additional user profile attributes, you must add additional fields to profile_user.jsp.
To add a new text field
- Add the following JSP code, which determines whether or not users can view the field based on their administrative role:
<%
bVisible = accessProperties.getVisible(role, "IDENTIFIER");
if (bVisible==true) { %>
In this statement:
- bVisible is a boolean. If the value of accessProperties.getVisible(role, "IDENTIFIER"); is true, Registration Services displays the field.
- accessProperties.getVisible tells the AccessTableBean to determine whether or not the field should be visible based on the entry in the presentation properties file.
- role is a parameter for the getVisible method. It identifies the administrator’s role
- IDENTIFIER is the identifier that is specified in the presentation properties file for the attribute that you are collecting
- Add the following JSP code, which determines the field label that is displayed in the collector JSP page:
<jsp:setProperty name="localebean" property="key"
value="IDENTIFIER" />
<jsp:getProperty name="localebean" property="label"/>
In these statements:
- IDENTIFIER is the identifier that is specified in the locale properties file for the attribute that you are collecting.
- jsp:setProperty and jsp:getProperty are the methods that call the locale bean, pass it the identifier, and retrieve the paired text string, which is displayed on the HTML form built by the JSP.
- Add the HTML and JSP code that creates the input field:
<tr>
<td>
<%
String attributeValue = properties.getValue("IDENTIFIER");
if ( attributeValue != null ) {
%>
<td><input type="text" size="42" maxlength="40"
name="IDENTIFIER" value= "<%= attributeValue %>">
</td>
<% } else { %>
<td><input type="text" size="42" maxlength="40"
name="IDENTIFIER">
</td>
<% } %>
<td><input type="hidden" size="42" maxlength="40"
name="INFO_IDENTIFIER">
</td>
</tr>
<% } %>
In these statements:
- IDENTIFIER is the identifier that is specified in the object properties file for the attribute that you are collecting.
- attributeValue holds the value returned by the properties.getValue method. attribute represents the name of the attribute that you are collecting. This attribute may have a value if an administrator is modifying an existing profile.
- if ( attributeValue != null ) tells Registration Services to display the value returned by properties.getValue if the value is not null. If the value is not null, the <input> statement that follows the if statement tells Registration Services to display the returned value.
- <% } else { %> tells Registration Services what to display if the value returned by properties.getValue is null. In this case, Registration Services displays an empty text box for the attribute, as defined by the <input> statement following the else statement.
- The third <input> statement holds a value if properties.getValue returns a value. This value is used as a flag for the checkForEmptyValues method. The checkForEmptyValuesMethod checks to see if the attribute has a value before and after a profile is modified. If the value exists before the modify action but not after, Registration Services removes the attribute from the profile.
- Add the attribute identifier to the checkForEmptyValues method. This method is located in newuserjs.jsp, which contains Javascript for managing users.
These files are included by the user_data_collector.jsp page.
Add the attribute identifier, as follows:
- Locate the function declaration for checkForEmptyValues:
function checkForEmptyValues()
- Add the attribute identifier to the list of identifiers, as follows:
listOfIds.add("IDENTIFIER");