| 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.
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.
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.
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.
Copyright © 2004, Sun Microsystems, Inc. All Rights Reserved.