C H A P T E R  43

Directory Search Model

The Directory Search Model allows us to uses a Model as a backing store for the LDAP Query's Result Set. This allows display fields to be bound to Directory attributes, and is a convenient approach when you have directory store and want to leverage automatic binding of these directory store values to a view. The runtime convenience is that the model provided pagination support and the results are scrollable bidirectionally.


Property Name

Description

Notes

Append Multiple Valued Attributes

This takes values True or False. If you want to append the multiple values of a single attribute, set this to True.

Required

Multiple Value Delimiter

This is used as a delimiter to append multiple values. This is ignored if the above property is set to false.

Optional

Root Context

This is the node from which the search is performed. Its value will be something like "ou=People,dc=sun,dc=com"

Required

Search Filter

Specify the filer for your search. This should be in he standard Directory search filter format. Eg: "(cn=anand*)"

Required


Also there are properties that can be programatically modified. SearchControl, InitialDirContext are few of the attributes that can be set programatically. Please refer to the Javadocs for more information on how to use these attributes.

Directory Search Model Design Actions

Start by creating Fields on the model. Name each field same as the attribute name in the LDAP. Alternatively you can use the "Attribute Name" instead to hold the attribute name and "Name" as just a logical name.

Fields


Property Name

Description

Notes

Attribute Name

This should match the attribute the name

Optional

Name

The logical name of the model field.

Required


How to Use This Component

1. Drag a DirectorySearchModel into your application.

2. Set the properties in the above table.

3. Add fields to the model. The Model Field name should be the same as the attribute name.

4. Multi-valued attributes can be concatenated to generate a single value

5. For each field Model Field Property "attribute" needs to be modified to match the attribute name in the LDAP server.

6. Create a Pagelet (tiled view) and associate this with the DirectorySearchModel.

7. Drag the required fields into your paglet.

8. Drag your paglet into a View Bean.

9. Create a submit button and a text field in your view bean.

10. When the user enters the search filter in the test field, get the value and set it to the model (in the handle request method of the button).

11. Now the model will update itself with the new result set, which will be displayed back to you.