You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by bj...@accenture.com on 2007/01/26 15:33:10 UTC

Loss of request attributes after validation form

Ok, I resolved the previous error, but now a new one pops up.

This is the situation:
We have a database in which we can look up certain persons.  When we find a person, we have the ability to register him in another database, with additional values.
If you find a user, you have a button to register him in the other database.  If you push that button, an object is put in the request in the following action (req.setAttribute("currentUser", currentUser)).  The next screen shows a form, with a few values already there, retrieved from the request (<c:out value=${currentUser.firstName} />) and some textfields to supply additional values (e.g. e-mail).  Now, when I push register, the validation is triggered and when it fails, you return to this screen.  The problem is that the request is cleared, right before that, so c:out shows nothing.  

Is there a way to solve this problem?  Or a workaround?

Björn De Bakker



 



This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information.  If you have received it in error, please notify the sender immediately and delete the original.  Any other use of the email by you is prohibited.

Re: Loss of request attributes after validation form

Posted by Laurie Harper <la...@holoweb.net>.
The clarification Paul asked for would be helpful, and I'd also suggest 
posting the form bean definition from struts-config.xml along with the 
action mappings for both displaying the form and handling its submission.

Re-reading your original post, I suspect you have an action in front of 
the form that puts an object into request scope then forwards to a JSP, 
but that the action the form submits to points directly at the JSP. If 
that's the case, your solution would be to point the 'input' attribute 
at the first action instead of at the JSP.

Whether that proves to be the problem or not, overloading validation() 
to push data into the request is probably not the best solution, since 
it will tightly couple your form processing with a single input source.

L.

bjorn.de.bakker@accenture.com wrote:
> Well, I'm using Struts 1.3.5 and DynaValidatorForm + validation.xml for validation.  We resolved the issue Friday, by performing some additional steps.  Instead of using DynaValidatorForm, we created our own class which extends DynaValidatorForm.  After we call the validate-method, and it fails, we add a new object to the request of the page.  It seems that, after you call "validate", a new request for the page is being sent, so if you don't add a new object to it, it "forgets" all those values.
> 
> If there are other solutions, please, feel free to share them.
> 
> Kind regards
> 
> Bjorn De Bakker
> 
> -----Original Message-----
> From: news [mailto:news@sea.gmane.org] On Behalf Of Laurie Harper
> Sent: zondag 28 januari 2007 0:26
> To: user@struts.apache.org
> Subject: Re: Loss of request attributes after validation form
> 
> bjorn.de.bakker@accenture.com wrote:
>> Ok, I resolved the previous error, but now a new one pops up.
>>
>> This is the situation:
>> We have a database in which we can look up certain persons.  When we find a person, we have the ability to register him in another database, with additional values.
>> If you find a user, you have a button to register him in the other database.  If you push that button, an object is put in the request in the following action (req.setAttribute("currentUser", currentUser)).  The next screen shows a form, with a few values already there, retrieved from the request (<c:out value=${currentUser.firstName} />) and some textfields to supply additional values (e.g. e-mail).  Now, when I push register, the validation is triggered and when it fails, you return to this screen.  The problem is that the request is cleared, right before that, so c:out shows nothing.  
>>
>> Is there a way to solve this problem?  Or a workaround?
> 
> What version of Struts are you using? How are you handling validation? 
> We will need more details about your setup and configuration to diagnose 
> this. It sounds like you're doing a redirect after validation, otherwise 
> the request shouldn't get cleared.
> 
> L.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 
> This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information.  If you have received it in error, please notify the sender immediately and delete the original.  Any other use of the email by you is prohibited.


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


RE: Re: Loss of request attributes after validation form

Posted by "Strachan, Paul" <Pa...@det.nsw.edu.au>.
Hi,
 
Can you be more specific regarding the data you are losing on validation?
e.g.
 
1. request attributes
 
when a new request is sent from the browser, the validation may occur before you have an opportunity to add further request attributes - in this case you should validate in your action code and set the request attributes you need for your view/jsp.
 
2. properties defined on your DynaForm
 
Your form properties are automatically populated by struts from the request before validation occurs, so this data should still be on the form when your view is rendered.  Struts form can be also defined as request or session scope.
 
AFAIK for struts to make a new request following validation error you would need to return an ActionForward mapping to a URL with redirect=true, using the "input" attribute or your own forward or global mapping.
 
Thanks,
Paul

________________________________

From: bjorn.de.bakker@accenture.com [mailto:bjorn.de.bakker@accenture.com]
Sent: Mon 1/29/2007 7:10 PM
To: user@struts.apache.org
Subject: RE: Re: Loss of request attributes after validation form



Well, I'm using Struts 1.3.5 and DynaValidatorForm + validation.xml for validation.  We resolved the issue Friday, by performing some additional steps.  Instead of using DynaValidatorForm, we created our own class which extends DynaValidatorForm.  After we call the validate-method, and it fails, we add a new object to the request of the page.  It seems that, after you call "validate", a new request for the page is being sent, so if you don't add a new object to it, it "forgets" all those values.

If there are other solutions, please, feel free to share them.

Kind regards

Bjorn De Bakker

-----Original Message-----
From: news [mailto:news@sea.gmane.org] On Behalf Of Laurie Harper
Sent: zondag 28 januari 2007 0:26
To: user@struts.apache.org
Subject: Re: Loss of request attributes after validation form

bjorn.de.bakker@accenture.com wrote:
> Ok, I resolved the previous error, but now a new one pops up.
>
> This is the situation:
> We have a database in which we can look up certain persons.  When we find a person, we have the ability to register him in another database, with additional values.
> If you find a user, you have a button to register him in the other database.  If you push that button, an object is put in the request in the following action (req.setAttribute("currentUser", currentUser)).  The next screen shows a form, with a few values already there, retrieved from the request (<c:out value=${currentUser.firstName} />) and some textfields to supply additional values (e.g. e-mail).  Now, when I push register, the validation is triggered and when it fails, you return to this screen.  The problem is that the request is cleared, right before that, so c:out shows nothing. 
>
> Is there a way to solve this problem?  Or a workaround?

What version of Struts are you using? How are you handling validation?
We will need more details about your setup and configuration to diagnose
this. It sounds like you're doing a redirect after validation, otherwise
the request shouldn't get cleared.

L.


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



This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information.  If you have received it in error, please notify the sender immediately and delete the original.  Any other use of the email by you is prohibited.

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



**********************************************************************
This message is intended for the addressee named and may contain
privileged information or confidential information or both. If you
are not the intended recipient please delete it and notify the sender.
**********************************************************************

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


RE: Re: Loss of request attributes after validation form

Posted by bj...@accenture.com.
Well, I'm using Struts 1.3.5 and DynaValidatorForm + validation.xml for validation.  We resolved the issue Friday, by performing some additional steps.  Instead of using DynaValidatorForm, we created our own class which extends DynaValidatorForm.  After we call the validate-method, and it fails, we add a new object to the request of the page.  It seems that, after you call "validate", a new request for the page is being sent, so if you don't add a new object to it, it "forgets" all those values.

If there are other solutions, please, feel free to share them.

Kind regards

Bjorn De Bakker

-----Original Message-----
From: news [mailto:news@sea.gmane.org] On Behalf Of Laurie Harper
Sent: zondag 28 januari 2007 0:26
To: user@struts.apache.org
Subject: Re: Loss of request attributes after validation form

bjorn.de.bakker@accenture.com wrote:
> Ok, I resolved the previous error, but now a new one pops up.
> 
> This is the situation:
> We have a database in which we can look up certain persons.  When we find a person, we have the ability to register him in another database, with additional values.
> If you find a user, you have a button to register him in the other database.  If you push that button, an object is put in the request in the following action (req.setAttribute("currentUser", currentUser)).  The next screen shows a form, with a few values already there, retrieved from the request (<c:out value=${currentUser.firstName} />) and some textfields to supply additional values (e.g. e-mail).  Now, when I push register, the validation is triggered and when it fails, you return to this screen.  The problem is that the request is cleared, right before that, so c:out shows nothing.  
> 
> Is there a way to solve this problem?  Or a workaround?

What version of Struts are you using? How are you handling validation? 
We will need more details about your setup and configuration to diagnose 
this. It sounds like you're doing a redirect after validation, otherwise 
the request shouldn't get cleared.

L.


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



This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information.  If you have received it in error, please notify the sender immediately and delete the original.  Any other use of the email by you is prohibited.

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


Re: Loss of request attributes after validation form

Posted by Laurie Harper <la...@holoweb.net>.
bjorn.de.bakker@accenture.com wrote:
> Ok, I resolved the previous error, but now a new one pops up.
> 
> This is the situation:
> We have a database in which we can look up certain persons.  When we find a person, we have the ability to register him in another database, with additional values.
> If you find a user, you have a button to register him in the other database.  If you push that button, an object is put in the request in the following action (req.setAttribute("currentUser", currentUser)).  The next screen shows a form, with a few values already there, retrieved from the request (<c:out value=${currentUser.firstName} />) and some textfields to supply additional values (e.g. e-mail).  Now, when I push register, the validation is triggered and when it fails, you return to this screen.  The problem is that the request is cleared, right before that, so c:out shows nothing.  
> 
> Is there a way to solve this problem?  Or a workaround?

What version of Struts are you using? How are you handling validation? 
We will need more details about your setup and configuration to diagnose 
this. It sounds like you're doing a redirect after validation, otherwise 
the request shouldn't get cleared.

L.


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