Alpha developers could add “Name” property in Client State
so that when using this Client state beta developers define its Name.
About this task
When developing new client state, the following steps
must be followed to include a “Name” property:
Procedure
- Define “Name” property in the corresponding state xml file:
<property name="id" defaultValue="" hidden="false" displayName="%Name" required="true" description="%DescriptionName" editRule="RuleName"/>
- Define the rule name class:
<extension
point="com.ibm.btt.tools.transaction.dominate.editorRules">
<rule
class="myPackage.MyRuleName" id="RuleName" description="description" >
</rule>
- Create the rule class.
To make this task
easy, BTT provides a property editor called StateNamePropertyEditor .
This class (or a subclass of it) should be invoked from the rule class createPropertyEditor method.
- StateNamePropertyEditor has two
constructors. Choose one of them depending on the needs:
- StateNamePropertyEditor(Attribute attr, Taggable
model). It should be invoked in case there is not
a necessary initial value in “Name”.
- StateNamePropertyEditor(Attribute attr, Taggable
model, String initialValue). Constructor that has
as third parameter the initial value to be set in the “Name” property.
It should be invoked in case an initial value different from blank
is necessary.
- Then there is a method in the StateNamePropertyEditor API
that should be overridden if necessary:
- String getNewValueIfEmpty(). It
should return the value to be set automatically in “Name” when it
is set to blank by the user. By default it returns an empty String.
So, it should be overridden at project-level in case a different value
needs to be set when “Name” is deleted (as it happens in Operation
state, where the “operation” property value is set in that case).
Example
As an example, this is the code corresponding to a new state
that sets “Name” property to “myInitial” value as well as it sets
automatically the value in “MyProperty” new property to “Name” when
it is emptied by the user.
public IPropertyEditor createPropertyEditor(Attribute attr, final Taggable model)
{
return new StateNamePropertyEditor(attr, model, “myInitial”)
{
public String getNewValueIfEmpty()
{
return getModel().getValueAt(getModel().getAttributeAt("MyProperty"));
}
};
}