[STRUTS] ActionForm reset

H

Hamvil

Hi,

I have a problem about the resest method of an ActionForm object.

Basicaly at the end of an execute method i would like to reset the
value passed to the current page.

So i write somethig like that:

((MyBean)actionForm).reset(actionMapping, httpServletRequest);

But if I try to reload the page with the associated form the various
fileds are already filled with the previous value.

What is the right procedure to reset the object httpServletRequest ???

Many Thanks
Roberto
 
R

Ryan Dillon

What kind of ActionForm are you using (session/request
custom/dynaform)? If it is a custom one, have you implemented the
reset() method to clear the variable?

Maybe you could explicitly clear the variable yourself, ie
actionForm.setSomeVar(null); before returning the ActionForward.

Cheers
 
W

Wendy S

Hamvil said:
I have a problem about the resest method of an ActionForm object.
Basicaly at the end of an execute method i would like to reset the
value passed to the current page.

If you put your form bean in request scope, it will automatically
"disappear" after each request.
So i write somethig like that:
((MyBean)actionForm).reset(actionMapping, httpServletRequest);

Did you write a reset method? The default implementation does nothing:
But if I try to reload the page with the associated form the various
fileds are already filled with the previous value.

This sounds like your form is in session scope and you haven't written
anything in your reset method.
 
K

kamal

If you have not write any code in the reset() method nothing will
happen just by calling that method.

Make sure you reset all the properties in the reset method.

If you have done that properly the scope of the form has no concern
here. If the form is in the request scope you will lose the data when
the request ends.
 
H

Hamvil

Wendy S said:
This sounds like your form is in session scope and you haven't written
anything in your reset method.

Yes the form is in the session scope, but i've wrote the reset method.
I will try to put the form in the request scope in order to see if the
behavior changes or not.

Thanks for the answer (i did not know that the form can be in session
or request scope)

Bye
Roberto
 
H

Hamvil

Thanks a lot Wendy is the second time in a row that you help me for
some struts related problems :)
 
Joined
Aug 17, 2010
Messages
1
Reaction score
0
You can define in your struts-action mapping what scope you want in your form like this way: <action path="/prosessAction" type="ActualJavaClassAction" name="nameOfTheForm" scope="request">
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top