struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Gainty <>
Subject RE: Best Practices for Forms
Date Mon, 02 Mar 2009 19:56:34 GMT


any reason why you would'nt put the attributes in Session by implementing SessionAware

put them in with setSession() and access with Map parameters=this.getSession()

Disclaimer and confidentiality note 
Everything in this e-mail and any attachments relates to the official business of Sender.
This transmission is of a confidential nature and Sender does not endorse distribution to
any party other than intended recipient. Sender does not necessarily endorse content contained
within this transmission. 

> Date: Mon, 2 Mar 2009 14:32:50 -0500
> From:
> To:
> Subject: Best Practices for Forms
> Hello All,
> I'm relatively new to Struts 2 and have a few questions as far as how to lay out a form
> I have the following scenario:
> 1. User is presented a form. (addData.jsp)
> 2. User submits form, we go off to an action to add form information to the database.
> 3. We send the user to a page that displays information about the data they just entered.
> The problem I was initially having was that, after step 2, I was using the dispatcher
result type to send the user to their view. SubmitData.action was providing viewData.jsp with
the necessary stack 
> values to fill in the page with the appropriate data.
> This was problematic, because at this point, due to the forward, the browser was still
at SubmitData.action, and refreshing the view caused the data to be submit again. To fix this,
I tried changing 
> the result type to redirect to the jsp page instead. This fixed the problem of the user
refreshing the page. The browser was now at viewData.jsp, so refreshing the page didn't submit
the data again.
> However, because I had redirected, I no longer had the value stack the SubmitData.action
provided, so I arrived at the view with no data. I can come up with ways to work around this,
but none of them 
> feel right. For instance, I can pass the necessary keys to viewData.jsp result like so:
> <action name="SubmitData" class="action.SubmitDataAction">
> 	<result name="success">/viewData.jsp?dataId=%{dataId}</result>
> </action>
> And then in the jsp page have action tags which gather the correct objects and put them
on the stack:
> <s:action name="GetData" namespace="/" var="data">
> 	<s:param name="dataId" value="%{dataId}" />
> </s:action>
> But again, this seems messy. What do people recommend? I know this has got to be a very
frequent case, I'm just not sure the best way to handle it.
> Thanks,
> Tim
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

Windows Liveā„¢ Contacts: Organize your contact list.!503D1D86EBB2B53C!2285.entry?ocid=TXT_TAGLM_WL_UGC_Contacts_032009
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message