Extend the Profiles application by adding custom extension attributes.
Before you begin
To edit configuration files, you must use the wsadmin client. See
Starting the wsadmin client for information about how to start the wsadmin command-line tool.
About this task
In addition to different attribute layouts, Profiles supports extension attributes for every profile type. Because all profiles share one schema, an extension attribute, such as customers, has the same semantic meaning for all profile types. However, you can choose to associate a particular attribute with a profile based on profile type. The user interface configuration, including display characteristics and whether an attribute can be edited, is also configurable for extension attributes based on profile type.
You can enable custom extension attributes by adding them to the
My Profile page. The attributes that display on the
My Profile page are specified using the
profiles-config.xml file located in the
<was_profile_root>config/cells<cell_name>/nodes/<node-name>/LotusConnections-config directory. Although changes to
profiles-config.xml should generally be made using wsadmin client scripting, there are no wsadmin commands to modify the profilesDataModel, so you can make changes to the profilesDataModel using a text editor.
There are three child elements under the profileDataModel element that correspond to the three sections in the
My Profile page in Profiles: jobInformation, contactInformation, and associatedInformation. The order in which the attributes display in the file reflects the order in which they display in the form. This correspondence means that you can easily reorder the attributes without needing to modify any JSP files.
The extension attributes that you define are always included as links in the output of the Profiles API unless you specify otherwise in the
profiles-config.xml file, as described in step 7 below. For more information about retrieving Profiles extensions through the API, see
Retrieving profile extension data.
Procedure
To add a custom extension attribute to the
My Profile page, perform the following steps.
- Start the wsadmin client from the following directory of the system on which you installed the Deployment Manager:
where <app_server_root> is the WebSphere® Application Server installation directory and <dm_profile_root> is the Deployment Manager profile directory, typically dmgr01.
You must start the client from this directory or subsequent commands that you enter do not execute correctly.
- Start the Profiles Jython script interpreter.
- Enter the following command to access the Profiles configuration files:
execfile("profilesAdmin.py") If prompted to specify a service to connect to, type 1 to pick the first node in the list. Most commands can run on any node. If the command writes or reads information to or from a file using a local file path, you must pick the node where the file is stored.
- Enter the following command to check out the Profiles configuration files:
ProfilesConfigService.checkOutConfig("<working_directory>", "<cell_name>")where:
- <working_directory> is the temporary working directory to which the configuration XML and XSD files are copied and are stored while you make changes to them. Use forward slashes (/) to separate directories in the file path, even if you are using the Microsoft Windows operating system.
Note: AIX and Linux only: The directory must grant write permissions or the command does not complete successfully.
- <cell_name> is the name of the WebSphere Application Server cell hosting the Profiles application. This argument is required. It is also case-sensitive, so type it with care. If you do not know the cell name, you can determine it by typing the following command in the wsadmin command processor: print AdminControl.getCell()
For example:
- AIX or Linux:
- Microsoft Windows:
- Save a copy of the profiles-config.xml file.
- Open the file in a text editor.
- To define the extension attribute, add it to the <profileExtensionAttributes> element under <profileDataModels> as follows:
<profileDataModels>
<profileExtensionAttributes>
<simpleAttribute extensionId="property1" length="64"/>
<simpleAttribute extensionId="property2" length="64"/>
<simpleAttribute extensionId="property3" length="64"/>
</profileExtensionAttributes>
<profileDataModel>
...
</profileDataModel>
...
</profileDataModels>
For example:
<profileDataModels>
<profileExtensionAttributes>
...
<simpleAttribute extensionId="spokenLang" length="64" />
<simpleAttribute extensionId="TechExperience" length="64" />
<simpleAttribute extensionId="officeAddress" length="64" />
<simpleAttribute extensionId="homeAddress" length="64" />
</profileExtensionAttributes>
</profileDataModels>
- To display the extension attribute, you need to associate it with a profile type. To do this, add the following line of code as a child element under the relevant profileType element, and under the appropriate page section, jobInformation, contactInformation, or associatedInformation:
<extensionAttribute showLabel="true" editable="true" extensionIdRef="extension_attribute_name"/>
The following table displays the XML attributes associated with the extensionAttribute element.
Table 1. XML attributes associated with extensionAttribute
| Attribute | Description |
| editable | Specifies if the extension attribute can be edited by users. This attribute takes a Boolean value. |
| showLabel | Specifies whether to display a label for the extension attribute in the user interface. The attribute takes a Boolean value. |
| hideIfEmpty | Specifies whether to hide the attribute if it does not have a value. This attribute takes a Boolean value. |
| link | This attribute takes a Boolean value. |
| extensionIdRef | The ID of the extension. This ID is associated with the property key in the resource file. This attribute takes a string value. |
| labelKey | Specifies the referenced key name of the label. This attribute takes a string value. |
| bundleIdRef | Specifies the referenced bundle ID of the label. This attribute takes a string value. |
| prependHtml | Specifies the HTML code prefixed to the value. This attribute takes a string value. |
| appendHtml | Specifies the HTML code appended to the value. This attribute takes a string value. |
For example, to display the officeAddress and homeAddress extension attributes in the Contact Information section of the page:
<layoutConfiguration>
<profileLayout profileType="student">
<contactInformation>
<extensionAttribute
showLabel="true"
editable="true"
extensionIdRef="officeAddress"/>
<extensionAttribute
showLabel="true"
editable="true"
extensionIdRef="homeAddress" />
<extensionAttribute
showLabel="true"
editable="true"
extensionIdRef="property1"
labelKey="label.contactInformation.property1"
bundleIdRef="customRes" />
...
</contactInformation>
</profileLayout>
</layoutConfiguration>
- To label the extension attribute, you need to add a resource string to the Profiles application. For more information, see Adding custom strings for widgets and other specified scenarios.
- Extension attributes are included in the output of the Profiles API by default. To prevent extension attributes from being included in the API, you need to define which attributes should not be output for each profile type. To do this, add the following line of code in the <apiConfiguration> section as a child element of the <apiModel> element for the relevant profileType.
<hiddenApiExtensionAttribute extensionIdRef="extension-id"/>
For example, to prevent the homeAddress extension attribute from appearing in API output for the default profile type, use this configuration:
<apiConfiguration>
<apiModel profileType="default">
<hiddenApiExtensionAttribute extensionIdRef="homeAddress"/>
...
</apiModel>
</apiConfiguration>
- After making changes, you must check the configuration files back in, and you must do so during the same wsadmin session in which you checked them out for the changes to take effect. See Applying property changes in Profiles for information about how to save and apply your changes.
Parent topic: Adding custom extension attributes for Profiles
Related tasks
Applying property changes in Profiles
Adding custom strings for widgets and other specified scenarios
Specifying a required field
Related reference
Retrieving profile extension data