Editing data with Struts and ActionForm

L

loris_p

Hi, I need to implement an "edit user" action in my web application.
This action will modify some data of selected user. To do this, I'm
using an ActionForm bean with editable properties.
I need the form on the web page to be populated with the data of
selected user. For example, if I'm editing "John Smith" I need that in
"Name" textbox there is "John" and in "Surname" one there is "Smith".
I think I have to initialize the form bean with the correct values,
but with reset() method I can only set default values and it doesn't
accept request object.
How can I do this?
 
D

david.karr

Hi, I need to implement an "edit user" action in my web application.
This action will modify some data of selected user. To do this, I'm
using an ActionForm bean with editable properties.
I need the form on the web page to be populated with the data of
selected user. For example, if I'm editing "John Smith" I need that in
"Name" textbox there is "John" and in "Surname" one there is "Smith".
I think I have to initialize the form bean with the correct values,
but with reset() method I can only set default values and it doesn't
accept request object.
How can I do this?

This isn't the best place to ask a question like this. Going to the
"struts-user" mailing list is a better bet.

However, I'll give this a try, even though it's been quite a while
since I've worked on a Struts app.

Typically, logic like this should not go into the ActionForm. The
ActionForm is intended to be a dumb container without business logic.
It's more appropriate to do this in an Action method. Define
something like a "prepare" step for the "edit user" action which
creates an ActionForm and populates it with the appropriate data
before forwarding to the edit user page.
 
L

loris_p

Thanks a lot :)
Now I'll try to do in that way.
Thanks also for telling me about that group.
 

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,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top