struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hernan gonzalez <hgonza...@gmail.com>
Subject Re: Best Practices for Forms
Date Mon, 02 Mar 2009 20:24:50 GMT
To avoid the problem of duplicated submissions (not only when
refreshing the result page, but also when double clicking the submit
button, or going back to the submited form and submitting again) you
should take a look at  the TokenSessionStoreInterceptor.

But that is complementary with the other issue: it is not bad practice
to separate the actions "addData " from the action "viewData", the
later is idempotent , the former is not. Hence, you might implement
two separate Actions (or a same Action with two methods that return
different results). For example

-------------------------------------------------------------------------------------
<action name="SubmitData" class="action.SubmitDataAction">
        <result name="success">/viewSubmitResult.jsp</result>
</action>

<action name="ViewData" class="action.ViewDataAction">
        <result name="success">/viewData.jsp</result>
</action>

(Here SubmitDataAction should include the Token interceptor to avoid
double submissions. And /viewSubmitResult.jsp might just show a
generic succes message with a link to the ViewDataAction action)

------------------------------------------------------------------------------------------------

or

<action name="SubmitData" class="action.SubmitDataAction">
        <result name="success"
type="redirect">ViewDataAction.do?id=%{dataId}</result>
</action>

<action name="ViewData" class="action.ViewDataAction">
        <result name="success">/viewData.jsp</result>
</action>

(This is a little more straightforward, but has the slight
disadvantage of losing any ActionMessage you might have produced in
the SubmitDataAction)

-----------------------------------------------------------------------------------------------------------------------

Hernán J. González
http://hjg.com.ar/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message