I've got a use case to edit an existing user.
I've extended the ForwardAction class to make one that forwards after
creating a transaction token.

When the user clicks on a link to edit a user's data, they are first
sent to an action that only
loads the user data into the form.  This action can be re-used by a
View User use case,
without any modification, because it doesn't create a transaction
token.
On success, that action forwards to the JSP page/tile via an action
that creates a transaction token.

When the user clicks save, the update action persists the data, and
forwards to JSP again
via the action that creates a transaction token.

I've seen it said here that you shouldn't chain actions, but it seems
more clear to me this way.
By doing it this way, I don't have to create tokens in my code.
The update action should not have to know that the place it is being
forwarded to will need
a transaction token.  Isn't the point of defining forwards for an
action that the java code
doesn't care where it is going to next?

<action-mappings>
    <!-- Action that only loads the user data -->
    <action
        path="/editUserAction"
        name="UserForm"
        type="com.whatever.LoadUserAction"
        validate="false"
        scope="request">
        <forward name="success" path="/editUser.do" />
        <forward name="failure" path="app.Home" />
    </action>

   <!-- Action that only creates a transaction token -->
    <action
        path="/editUser"
        type="com.whatever.TransactionForwardAction"
        parameter="app.EditUser"/>

    <!-- Action that persists the user data (consumes the transaction
token) -->
    <action
        path="/updateUserAction"
        name="UserForm"
        type="com.whatever.UpdateUserAction"
        validate="true"
        input="app.EditUser"
        scope="request">
        <forward name="success" path="/editUser.do" />
        <forward name="cancel" path="app.Home" />
        <forward name="failure" path="/editUser.do" />
    </action>

</action-mappings>


In any case, in doing this, it seems to me that it would make sense if
you could
make an action create a transaction token by some entry in the
struts-config.



--
Steve Stair
[EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to