initAndValidateAttributes()

Initializes attributes that do not have values set, but are marked as required, with their default values.

Syntax

public static void initAndValidateAttributes(
     BusinessObjectInterface theBusObj);
 

Parameters

theBusObj
Is the business object whose attributes this method sets.

Return values

None.

Exceptions

BusObjSpecNameNotFoundException
Thrown when the name of the specified business object does not match any of the business object definitions in the repository.
SetDefaultFailedException
Thrown when the attribute's default value could not be set and there is no default value specified for the attribute in the business object definition.

Notes

The initAndValidateAttributes() method has two purposes:

The initAndValidateAttributes()method looks at 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. To have initAndValidateAttributes() set the attribute value to the special Blank value (CxBlank), you can set the attribute's default value to the string "CxBlank". If the attribute does not have a default value, initAndValidateAttributes() throws the SetDefaultFailedException exception.

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 the initAndValidateAttributes() method 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:

Copyright IBM Corp. 1997, 2004