custom-attribute handler
Generates virtual attributes derived from other attributes or external elements of the application. It can be applied to any DataNode to add attributes that were not originally present at the underlying business object. Those attributes will be presented at the JXPath interface just as if they were business objects attributes
Attribute
|
Usage
|
---|---|
name |
Name of the virtual attribute |
expr | EL expression that evaluates de attribute value |
if |
EL expression that must be evaluated to true prior to handler action |
unless |
EL expression that must be evaluated to false prior to handler action |
depends | XPath to a attribute or business object the expression depends on |
It's important to properly set the depends attribute as long as the attribute will be reevaluated whenever a dependent attribute has been changed.
The custom attribute can have an empty EL expressions and use a BeanShell script instead. Here is an example of both aproaches:
<datanode name="network">
<custom-attribute name=”networkMask1” expr=”${instance.network}/${instance.mask}”>
<custom-attribute name=”networkMask2”>
<depends>@network</depends>
<depends>@mask</depends>
return instance.network + “/” + instance.mask;
</custom-attribute>
...
</datanode>