Common Action classes behaviour
Hi,
Most of the Action classes we are developing get or set an object from/to one of the two scopes, request or flow. Also, we like to be able to configure the name of the attribute and which scope to use, much like the FormAction.
First we were going to move this common code to a parent Action class which inherited from AbstractAction, but as we also have MultiActions, we created a separated helper class. Then, we define our actions like this:
Code:
<bean id="MyAction"
class="com.disid.MyAction">
<property name="attributeName">
<value>MyObject</value>
</property>
<property name="objectScopeAsString">
<value>flow</value>
</property>
</bean>
And then, from my action class, I can get or set the object from the scope like this:
Code:
Object object = getScopeHelper().getScopeObject(context);
getScopeHelper().storeScopeObject(element, context);
Maybe this functionality could be moved to the AbstractAction class, as I think it is going to be very common in general. What do you think?
Cèsar
Jira issue SPR-901 created
Hi Keith,
I have created the Jira issue SPR-901 with the related code. I hope you find it useful.
Thanks!
Cèsar