You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Leandro Melo <lt...@yahoo.com.br> on 2004/08/13 04:08:30 UTC

Loosing request attributes

Hi,
when a user request hits the ActionForm's validate
method and bounces back, i'm loosing some request
attributes that i had set for the page. In other
words, if the user inputs some data that don't pass
the validate method,
the page comes back with a few request scope
attributes missing.

Is there a way to avoid that this happens?

=====
_________________________________
Leandro Terra C. Melo
Eng. de Controle e Automação - UFMG


	
	
		
_______________________________________________________
Yahoo! Acesso Grátis - navegue de graça com conexão de qualidade! Acesse: http://br.acesso.yahoo.com/

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


Re: Loosing request attributes

Posted by Leandro Melo <lt...@yahoo.com.br>.
Erik,
i'm not talking about form attributes, that's what i
said in my last e-mail.
I'll try to clear it out.
Suppose a user submits a request that is handled by
MyActionDoSomething. Then this action sets a request
attribute like this:

request.setAttribute("MyObject", obj); 

and forwards the request to the page
myPageDoSomeOtherThing.jsp, wich has some inputs for
the user to fill in.
This page (myPageDoSomeOtherThing.jsp) uses the bean
"obj" that was set in MyActionDoSomething.java ok !?

Now suppose the user submits wrong information in
myPageDoSomeOtherThing.jsp, what will cause the
validate method in the associated ActionForm to return
some ActionErrors. BUT when the ActionForm send this
page back for the user to re-input data, the bean
"obj" that was set at the very beginning in
MyActionDoSomething.java is NOT present anymore!

I think now it's clear that i'm not talking about the
formBean attributes, right !? 








 --- Erik Weber <er...@mindspring.com> escreveu: 
> You shouldn't have to do anything (in general, you
> rarely need to 
> implement reset) special for this. Struts does this
> for you. The user 
> submits the form. The form bean is populated with
> the user's input. 
> Validation starts on the form bean. Validation
> fails. Struts forwards 
> back to the input page, and the struts tags render
> all the values that 
> the user had input using the populated form bean.
> 
> Could you describe in more detail which types of
> form values seem to be 
> "missing" and which ones are intact? Is there a
> pattern to it?
> 
> Erik
> 
> 
> 
> Leandro Melo wrote:
> 
> >I don`t want to reset the attributes of my
> ActionForm
> >(what a form.reset() would do), BUT the attributes
> of
> >the request the were probably set by the Action
> that
> >forwarded to the specific page.
> >
> >So i need them back in that page if validate fails.
> >
> >
> > --- Robert Taylor <rt...@mulework.com> escreveu:
> 
> >  
> >
> >>form.reset();
> >>
> >>robert
> >>
> >>    
> >>
> >>>-----Original Message-----
> >>>From: Leandro Melo
> >>>      
> >>>
> >>[mailto:ltcmelo_java@yahoo.com.br]
> >>    
> >>
> >>>Sent: Friday, August 13, 2004 11:20 AM
> >>>To: Struts Users Mailing List
> >>>Subject: Re: Loosing request attributes
> >>>
> >>>
> >>>I was taking a look at the HttpServeltRequest and
> >>>ServletRequest apis and noted that theres a
> method
> >>>"getParameterMap()" wich returns a map of the
> >>>parameters, BUT there isn`t such a
> >>>      
> >>>
> >>"setParameterMap()"
> >>    
> >>
> >>>method.
> >>>
> >>>So, what`s an automated way to re-set all my
> >>>      
> >>>
> >>request
> >>    
> >>
> >>>parameters in the ActionForm??? Do i have to go
> >>>      
> >>>
> >>one by
> >>    
> >>
> >>>one for each ActionForm :-( ???
> >>>
> >>>
> >>> --- "Ruth, Brice" <br...@fiskars.com> escreveu:
> >>>      
> >>>
> >>>>Ensure that the request attributes are set in
> >>>>        
> >>>>
> >>the
> >>    
> >>
> >>>>ActionForm, this is
> >>>>the only way that you can ensure that they'll
> >>>>        
> >>>>
> >>still
> >>    
> >>
> >>>>be there when the
> >>>>validate fails.
> >>>>
> >>>>Leandro Melo wrote:
> >>>>
> >>>>        
> >>>>
> >>>>>Hi,
> >>>>>when a user request hits the ActionForm's
> >>>>>          
> >>>>>
> >>validate
> >>    
> >>
> >>>>>method and bounces back, i'm loosing some
> >>>>>          
> >>>>>
> >>request
> >>    
> >>
> >>>>>attributes that i had set for the page. In
> >>>>>          
> >>>>>
> >>other
> >>    
> >>
> >>>>>words, if the user inputs some data that don't
> >>>>>          
> >>>>>
> >>pass
> >>    
> >>
> >>>>>the validate method,
> >>>>>the page comes back with a few request scope
> >>>>>attributes missing.
> >>>>>
> >>>>>Is there a way to avoid that this happens?
> >>>>>
> >>>>>=====
> >>>>>_________________________________
> >>>>>Leandro Terra C. Melo
> >>>>>Eng. de Controle e Automação - UFMG
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>          
> >>>>>
>
>>_______________________________________________________
> >>    
> >>
> >>>>>Yahoo! Acesso Grátis - navegue de graça com
> >>>>>          
> >>>>>
> >>conexão
> >>    
> >>
> >>>>de qualidade! Acesse:
> >>>>        
> >>>>
> >>http://br.acesso.yahoo.com/
> >>    
> >>
>
>>---------------------------------------------------------------------
> >>    
> >>
> >>>>>To unsubscribe, e-mail:
> >>>>>          
> >>>>>
> >>>>user-unsubscribe@struts.apache.org
> >>>>        
> >>>>
> >>>>>For additional commands, e-mail:
> >>>>>          
> >>>>>
> >>>>user-help@struts.apache.org
> >>>>        
> >>>>
> >>>>>
> >>>>>          
> >>>>>
> >>>>--
> >>>>Brice Ruth, Sr. IT Analyst
> >>>>Fiskars Brands Inc
> >>>>http://www.fiskarsbrands.com/
> >>>>
> >>>>
> >>>>
> >>>>        
> >>>>
>
>---------------------------------------------------------------------
> >  
> >
> >>>>To unsubscribe, e-mail:
> >>>>user-unsubscribe@struts.apache.org
> >>>>For additional commands, e-mail:
> >>>>user-help@struts.apache.org
> >>>>
> >>>>
> >>>>        
> >>>>
> 
=== message truncated === 

=====



	
	
		
_______________________________________________________
Yahoo! Acesso Grátis - navegue de graça com conexão de qualidade! Acesse: http://br.acesso.yahoo.com/

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


Re: Loosing request attributes

Posted by Erik Weber <er...@mindspring.com>.
You shouldn't have to do anything (in general, you rarely need to 
implement reset) special for this. Struts does this for you. The user 
submits the form. The form bean is populated with the user's input. 
Validation starts on the form bean. Validation fails. Struts forwards 
back to the input page, and the struts tags render all the values that 
the user had input using the populated form bean.

Could you describe in more detail which types of form values seem to be 
"missing" and which ones are intact? Is there a pattern to it?

Erik



Leandro Melo wrote:

>I don`t want to reset the attributes of my ActionForm
>(what a form.reset() would do), BUT the attributes of
>the request the were probably set by the Action that
>forwarded to the specific page.
>
>So i need them back in that page if validate fails.
>
>
> --- Robert Taylor <rt...@mulework.com> escreveu: 
>  
>
>>form.reset();
>>
>>robert
>>
>>    
>>
>>>-----Original Message-----
>>>From: Leandro Melo
>>>      
>>>
>>[mailto:ltcmelo_java@yahoo.com.br]
>>    
>>
>>>Sent: Friday, August 13, 2004 11:20 AM
>>>To: Struts Users Mailing List
>>>Subject: Re: Loosing request attributes
>>>
>>>
>>>I was taking a look at the HttpServeltRequest and
>>>ServletRequest apis and noted that theres a method
>>>"getParameterMap()" wich returns a map of the
>>>parameters, BUT there isn`t such a
>>>      
>>>
>>"setParameterMap()"
>>    
>>
>>>method.
>>>
>>>So, what`s an automated way to re-set all my
>>>      
>>>
>>request
>>    
>>
>>>parameters in the ActionForm??? Do i have to go
>>>      
>>>
>>one by
>>    
>>
>>>one for each ActionForm :-( ???
>>>
>>>
>>> --- "Ruth, Brice" <br...@fiskars.com> escreveu:
>>>      
>>>
>>>>Ensure that the request attributes are set in
>>>>        
>>>>
>>the
>>    
>>
>>>>ActionForm, this is
>>>>the only way that you can ensure that they'll
>>>>        
>>>>
>>still
>>    
>>
>>>>be there when the
>>>>validate fails.
>>>>
>>>>Leandro Melo wrote:
>>>>
>>>>        
>>>>
>>>>>Hi,
>>>>>when a user request hits the ActionForm's
>>>>>          
>>>>>
>>validate
>>    
>>
>>>>>method and bounces back, i'm loosing some
>>>>>          
>>>>>
>>request
>>    
>>
>>>>>attributes that i had set for the page. In
>>>>>          
>>>>>
>>other
>>    
>>
>>>>>words, if the user inputs some data that don't
>>>>>          
>>>>>
>>pass
>>    
>>
>>>>>the validate method,
>>>>>the page comes back with a few request scope
>>>>>attributes missing.
>>>>>
>>>>>Is there a way to avoid that this happens?
>>>>>
>>>>>=====
>>>>>_________________________________
>>>>>Leandro Terra C. Melo
>>>>>Eng. de Controle e Automação - UFMG
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>          
>>>>>
>>_______________________________________________________
>>    
>>
>>>>>Yahoo! Acesso Grátis - navegue de graça com
>>>>>          
>>>>>
>>conexão
>>    
>>
>>>>de qualidade! Acesse:
>>>>        
>>>>
>>http://br.acesso.yahoo.com/
>>    
>>
>>---------------------------------------------------------------------
>>    
>>
>>>>>To unsubscribe, e-mail:
>>>>>          
>>>>>
>>>>user-unsubscribe@struts.apache.org
>>>>        
>>>>
>>>>>For additional commands, e-mail:
>>>>>          
>>>>>
>>>>user-help@struts.apache.org
>>>>        
>>>>
>>>>>
>>>>>          
>>>>>
>>>>--
>>>>Brice Ruth, Sr. IT Analyst
>>>>Fiskars Brands Inc
>>>>http://www.fiskarsbrands.com/
>>>>
>>>>
>>>>
>>>>        
>>>>
>---------------------------------------------------------------------
>  
>
>>>>To unsubscribe, e-mail:
>>>>user-unsubscribe@struts.apache.org
>>>>For additional commands, e-mail:
>>>>user-help@struts.apache.org
>>>>
>>>>
>>>>        
>>>>
>>>=====
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>      
>>>
>_______________________________________________________
>  
>
>>>Yahoo! Acesso Grátis - navegue de graça com
>>>      
>>>
>>conexão de qualidade! Acesse:
>>http://br.acesso.yahoo.com/
>>    
>>
>>>      
>>>
>---------------------------------------------------------------------
>  
>
>>>To unsubscribe, e-mail:
>>>      
>>>
>>user-unsubscribe@struts.apache.org
>>    
>>
>>>For additional commands, e-mail:
>>>      
>>>
>>user-help@struts.apache.org
>>    
>>
>>
>>    
>>
>---------------------------------------------------------------------
>  
>
>>To unsubscribe, e-mail:
>>user-unsubscribe@struts.apache.org
>>For additional commands, e-mail:
>>user-help@struts.apache.org
>>
>> 
>>    
>>
>
>=====
>
>
>
>	
>	
>		
>_______________________________________________________
>Yahoo! Acesso Grátis - navegue de graça com conexão de qualidade! Acesse: http://br.acesso.yahoo.com/
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>
>
>  
>

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


RE: Loosing request attributes

Posted by Leandro Melo <lt...@yahoo.com.br>.
I don`t want to reset the attributes of my ActionForm
(what a form.reset() would do), BUT the attributes of
the request the were probably set by the Action that
forwarded to the specific page.

So i need them back in that page if validate fails.


 --- Robert Taylor <rt...@mulework.com> escreveu: 
> form.reset();
> 
> robert
> 
> > -----Original Message-----
> > From: Leandro Melo
> [mailto:ltcmelo_java@yahoo.com.br]
> > Sent: Friday, August 13, 2004 11:20 AM
> > To: Struts Users Mailing List
> > Subject: Re: Loosing request attributes
> >
> >
> > I was taking a look at the HttpServeltRequest and
> > ServletRequest apis and noted that theres a method
> > "getParameterMap()" wich returns a map of the
> > parameters, BUT there isn`t such a
> "setParameterMap()"
> > method.
> >
> > So, what`s an automated way to re-set all my
> request
> > parameters in the ActionForm??? Do i have to go
> one by
> > one for each ActionForm :-( ???
> >
> >
> >  --- "Ruth, Brice" <br...@fiskars.com> escreveu:
> > > Ensure that the request attributes are set in
> the
> > > ActionForm, this is
> > > the only way that you can ensure that they'll
> still
> > > be there when the
> > > validate fails.
> > >
> > > Leandro Melo wrote:
> > >
> > > >Hi,
> > > >when a user request hits the ActionForm's
> validate
> > > >method and bounces back, i'm loosing some
> request
> > > >attributes that i had set for the page. In
> other
> > > >words, if the user inputs some data that don't
> pass
> > > >the validate method,
> > > >the page comes back with a few request scope
> > > >attributes missing.
> > > >
> > > >Is there a way to avoid that this happens?
> > > >
> > > >=====
> > > >_________________________________
> > > >Leandro Terra C. Melo
> > > >Eng. de Controle e Automação - UFMG
> > > >
> > > >
> > > >
> > > >
> > > >
> > >
> >
>
>_______________________________________________________
> > > >Yahoo! Acesso Grátis - navegue de graça com
> conexão
> > > de qualidade! Acesse:
> http://br.acesso.yahoo.com/
> > > >
> > >
> >
>
>---------------------------------------------------------------------
> > > >To unsubscribe, e-mail:
> > > user-unsubscribe@struts.apache.org
> > > >For additional commands, e-mail:
> > > user-help@struts.apache.org
> > > >
> > > >
> > > >
> > >
> > > --
> > > Brice Ruth, Sr. IT Analyst
> > > Fiskars Brands Inc
> > > http://www.fiskarsbrands.com/
> > >
> > >
> > >
> >
>
---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> > > user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail:
> > > user-help@struts.apache.org
> > >
> > >
> >
> > =====
> >
> >
> >
> >
> >
> >
> >
>
_______________________________________________________
> > Yahoo! Acesso Grátis - navegue de graça com
> conexão de qualidade! Acesse:
> http://br.acesso.yahoo.com/
> >
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> > For additional commands, e-mail:
> user-help@struts.apache.org
> >
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
> 
>  

=====



	
	
		
_______________________________________________________
Yahoo! Acesso Grátis - navegue de graça com conexão de qualidade! Acesse: http://br.acesso.yahoo.com/

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


RE: Loosing request attributes

Posted by Robert Taylor <rt...@mulework.com>.
form.reset();

robert

> -----Original Message-----
> From: Leandro Melo [mailto:ltcmelo_java@yahoo.com.br]
> Sent: Friday, August 13, 2004 11:20 AM
> To: Struts Users Mailing List
> Subject: Re: Loosing request attributes
>
>
> I was taking a look at the HttpServeltRequest and
> ServletRequest apis and noted that theres a method
> "getParameterMap()" wich returns a map of the
> parameters, BUT there isn`t such a "setParameterMap()"
> method.
>
> So, what`s an automated way to re-set all my request
> parameters in the ActionForm??? Do i have to go one by
> one for each ActionForm :-( ???
>
>
>  --- "Ruth, Brice" <br...@fiskars.com> escreveu:
> > Ensure that the request attributes are set in the
> > ActionForm, this is
> > the only way that you can ensure that they'll still
> > be there when the
> > validate fails.
> >
> > Leandro Melo wrote:
> >
> > >Hi,
> > >when a user request hits the ActionForm's validate
> > >method and bounces back, i'm loosing some request
> > >attributes that i had set for the page. In other
> > >words, if the user inputs some data that don't pass
> > >the validate method,
> > >the page comes back with a few request scope
> > >attributes missing.
> > >
> > >Is there a way to avoid that this happens?
> > >
> > >=====
> > >_________________________________
> > >Leandro Terra C. Melo
> > >Eng. de Controle e Automação - UFMG
> > >
> > >
> > >
> > >
> > >
> >
> >_______________________________________________________
> > >Yahoo! Acesso Grátis - navegue de graça com conexão
> > de qualidade! Acesse: http://br.acesso.yahoo.com/
> > >
> >
> >---------------------------------------------------------------------
> > >To unsubscribe, e-mail:
> > user-unsubscribe@struts.apache.org
> > >For additional commands, e-mail:
> > user-help@struts.apache.org
> > >
> > >
> > >
> >
> > --
> > Brice Ruth, Sr. IT Analyst
> > Fiskars Brands Inc
> > http://www.fiskarsbrands.com/
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > user-unsubscribe@struts.apache.org
> > For additional commands, e-mail:
> > user-help@struts.apache.org
> >
> >
>
> =====
>
>
>
>
>
>
> _______________________________________________________
> Yahoo! Acesso Grátis - navegue de graça com conexão de qualidade! Acesse: http://br.acesso.yahoo.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>


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


Re: Loosing request attributes

Posted by Leandro Melo <lt...@yahoo.com.br>.
I was taking a look at the HttpServeltRequest and
ServletRequest apis and noted that theres a method
"getParameterMap()" wich returns a map of the
parameters, BUT there isn`t such a "setParameterMap()"
method.

So, what`s an automated way to re-set all my request
parameters in the ActionForm??? Do i have to go one by
one for each ActionForm :-( ???


 --- "Ruth, Brice" <br...@fiskars.com> escreveu: 
> Ensure that the request attributes are set in the
> ActionForm, this is 
> the only way that you can ensure that they'll still
> be there when the 
> validate fails.
> 
> Leandro Melo wrote:
> 
> >Hi,
> >when a user request hits the ActionForm's validate
> >method and bounces back, i'm loosing some request
> >attributes that i had set for the page. In other
> >words, if the user inputs some data that don't pass
> >the validate method,
> >the page comes back with a few request scope
> >attributes missing.
> >
> >Is there a way to avoid that this happens?
> >
> >=====
> >_________________________________
> >Leandro Terra C. Melo
> >Eng. de Controle e Automação - UFMG
> >
> >
> >	
> >	
> >		
>
>_______________________________________________________
> >Yahoo! Acesso Grátis - navegue de graça com conexão
> de qualidade! Acesse: http://br.acesso.yahoo.com/
> >
>
>---------------------------------------------------------------------
> >To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> >For additional commands, e-mail:
> user-help@struts.apache.org
> >
> >  
> >
> 
> -- 
> Brice Ruth, Sr. IT Analyst
> Fiskars Brands Inc
> http://www.fiskarsbrands.com/
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
> 
>  

=====



	
	
		
_______________________________________________________
Yahoo! Acesso Grátis - navegue de graça com conexão de qualidade! Acesse: http://br.acesso.yahoo.com/

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


Re: Loosing request attributes

Posted by "Ruth, Brice" <br...@fiskars.com>.
Ensure that the request attributes are set in the ActionForm, this is 
the only way that you can ensure that they'll still be there when the 
validate fails.

Leandro Melo wrote:

>Hi,
>when a user request hits the ActionForm's validate
>method and bounces back, i'm loosing some request
>attributes that i had set for the page. In other
>words, if the user inputs some data that don't pass
>the validate method,
>the page comes back with a few request scope
>attributes missing.
>
>Is there a way to avoid that this happens?
>
>=====
>_________________________________
>Leandro Terra C. Melo
>Eng. de Controle e Automação - UFMG
>
>
>	
>	
>		
>_______________________________________________________
>Yahoo! Acesso Grátis - navegue de graça com conexão de qualidade! Acesse: http://br.acesso.yahoo.com/
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>
>  
>

-- 
Brice Ruth, Sr. IT Analyst
Fiskars Brands Inc
http://www.fiskarsbrands.com/


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