initAndValidateAttributes()

Initializes attributes with default values and validates that required values exist.

Syntax

bool initAndValidateAttributes();
 

Parameters

None.

Return values

Returns TRUE if after processing default values if all required attributes have been set (have non-null values). If a required value has not been set and there is no default value specified for the attribute in the business object definition, returns FALSE.

Notes

The initAndValidateAttributes() method has two purposes:

The initAndValidateAttributes() method loops through every attribute in all levels of a business object and determines the following:

If an attribute is required and UseDefaults is true, initAndValidateAttributes() sets the value of any unset attribute to its default value. If the attribute does not have a default value, initAndValidateAttributes() returns FALSE.

Note:
If an attribute is a key or other attribute whose value is generated by the application, the business object definition should not provide default values, and the Required property for the attribute should be set to false.

The initAndValidateAttributes() method is usually called from the business-object-handler doVerbFor() method to ensure that required attributes have values before a Create operation is performed in an application. In the doVerbFor() method, you can call initAndValidateAttributes() for the Create verb. You can also call it for the Update verb, before it performs a Create.

To use initAndValidateAttributes(), you must also do the following:

Examples

int ExampleBOHandler::doVerbFor(BusinessObject &theObj,
    ReturnStatusDescriptor *rtnStatusMsg)
 {
    int status = BON_SUCCESS;
  
    // Determine the verb of the incoming business object
    char *verb = theObj.getVerb();
  
    if (strcmp(verb, CREATE) == 0)
       {
          if (!theObj->initAndValidateAttributes())
             return BON_FAIL;
       }
    else ...
 

Copyright IBM Corp. 1997, 2004