struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Timothy Orme <>
Subject Re: Best Practices for Forms
Date Mon, 02 Mar 2009 20:19:18 GMT
I'm not really sure what you're suggesting here. Are you saying that I should put the dataId
attribute in the session instead of passing it to the page? I'm not really sure what that
helps, and in 
fact it only seems to complicate the issue. Maybe I'm misunderstanding?


Martin Gainty wrote:
> Tim-
> 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()
> Martin 
> ______________________________________________ 
> 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 correctly.
>> 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. (viewData.jsp)
>> 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
>> <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. 

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message