• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

prepopulate and update data

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello ,

I am able to prepopulate the form by forwarding teh form to an intermediate action class. But after prepopulation, if I try to save the data as it is, without updating, all teh values in the form bean are null (unless I manually set the values). How is it able to populate then.

Please help me in understanding it.
Thanks!
[ February 17, 2005: Message edited by: sunitha Veda ]
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sunitha,

I'd love to help, but I'm afraid I can't make sense of what you are doing. It would be helpful if you could be more specific on what the flow of information is, and at what point the values are null. It would also be helpful to indicate what the scope each of the forms are in. For example:

1. user calls actionA
2. actionA populates FormA
3. ActionA puts FormA in the request
4. JspA reads values in FormA and values are null.

One of the biggest mistakes made by beginners in struts is that they forget to place the form bean in the proper scope object. For example, if the form is scoped to the session, in the Action class, you must include the statement:

request.getSession().setAttribute("MyForm", myForm);

if the form is scoped to the request, you must include the statement:

request.setAttribute("MyForm", myForm);

This assumes that the name of your form is MyForm, and that you have defined a variable of type MyForm named myForm, and have poplulated it's values.

If this explanation solves your problem, great.

If not, please provide the information I asked for, and I'll try to help you figure this out.

Merrill
 
sunitha Veda
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Merrill,
I am really glasd that you are trying to help me out.

This is the flow of the application -

1. To update the employee info, I enter his name in a text field and click update.
2. In the LookupDispatchAction, update() method, I request get his info in database.

3. Then, in the same update method, I create
MyForm myForm = new MyForm();
Implement all the setters say, myForm.setAge() myForm.setDate() etc... with the values from the database.

4. Still in teh update method, I say,
request.setAttribute("myForm", myForm);
return mapping.findforward("update");

5. In the update screen, I see that teh form is populated with the relevant information.

6. At this point of time, if I decide not to update and click save, all teh form valeus are null.

Thanks for yoru time!
 
reply
    Bookmark Topic Watch Topic
  • New Topic