Additional Information in Attribute Hooks

The calculation of an attribute implementation may differs depending on whether attributes are specified in the request or not. However, an empty value can indicate either the (optional) attribute value was unavailable in the request, or the attribute value was available but happened to be empty. For that reason, the developer who is coding the hook must be able to determine which input attributes are set.

In before/on/after get/set hooks a parameter is available to indicate whether the value for an attribute implementation is set. Note that an on set hook is invoked if at least one of the used attributes is set. So if multiple used attributes exist, some of those may not be set. However, if none of the used attributes is set then the setter is not invoked. By the way, if an attribute has no used attributes at all, the on set hook is always invoked.

For the attribute implementation that is output for a hook, a parameter is available to indicate whether the value is set. By default the value will be true; so it only needs to be set if false.

An example of using an ‘isSet’ parameter in a before set hook:

if not i.orderStatus.isSet then
	 	io.cancel = true
endif
return(0) | OK

An example of using ‘isSet’ parameters in an on set or on get hook:

if i.value1.isSet then
		 if i.value2.isSet then
			   o.calculatedValue = i.value1 * i.value2
		 else
			   o.calculatedValue = i.value1 * i.value3
		 endif
else
		 io.calculatedValue.isSet = false
endif
return(0) | OK