Home

 

Specify a required field

You can make a custom field into a required field by editing the validation.xml file.


Lotus Connections is built on Struts, which means you can leverage the Struts validation framework to validate form data. The files validation.xml and validation-rules.xml are both part of the Struts validation framework. The validation.xml file defines the validation types that are applied to form fields; validation-rules.xml defines a set of standard validation routines. Validation routines, such as "required" and "maximum length", are included in the validation framework.

To make a custom extension field a required field, perform the following steps:

  1. Save a copy of the <was_profile_root>\installedApps\cell_name\profiles.ear\peoplepages.war\WEB-INF\validation.xml file.

  2. Open the file in a text editor, and specify your validation requirements using the information in the following table:


    Attributes of the validator

    Attribute Role
    property The name of the field that you want to make required. You obtain the field name by viewing the source of the rendered page.
    depends The name of the validation to run.
    msg name Overrides the default required error message. This value matches the validator's name attribute.
    msg key The message to be displayed when the validation fails. The key in the property file contains the error message to display when validation fails. You need to add the key to the property file.

    For example:

      <form-validation>
       <formset>
        <form name="editProfileForm">
         <field property="attribute(contactInformation.property1)" depends="required">
          <msg name="required" key="errors.requiredfield" />
         </field>
         <field property="attribute(associatedInformation.description)" depends="maxlength">
          <msg name="maxlength" key="errors.aboutMe" />
           <var>
            <var-name>maxlength</var-name>
            <var-value>1500</var-value>
           </var>
          </field>
      

  3. Finally, create a new entry in the resources-general.properties file of the Profiles feature to create a custom error message to be displayed when the validation fails. Create the property file entry with the key specified in the key attribute of the msg element. For example:

      errors.requiredfield=Mentor value is missing
      

    This example generates a message "Mentor value is missing" when users do not enter a mentor name before they save their profile.


Add custom extension attributes for Profiles


+

Search Tips   |   Advanced Search