Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Struts - basic form submission -- variable changed values not holding

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am working with multiple records in a Form.


struts-config:


Form:



JSP:




EditRecordObject:


I'm able to display the data just fine. But when I change a value in a text field, the action doesn't recognize the new value. The request variable doesn’t get loaded when I submit the action and/or the session variable doesn’t get reset.
Any help will be greatly appreciated.
 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Can you post your action code... ?

How do you access the Nested Objects ?
 
Erica Johnson
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your help!

This is how the data is loaded in the first place:
 
 

 
 
getTestRecords method logic:

 
 
 
 
and then TestUpdateSubmitAction just tries to read the form, but it's not updated:
 
 
Vicky Vijay
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Erica Johnson wrote:
and then TestUpdateSubmitAction just tries to read the form, but it's not updated:
 



You are trying to access the Objects from the request...

Try accessing using the ActionForm,


 
Ranch Hand
Posts: 41
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What Vijay said. Why even set the form in scope as an attribute and try to retrieve again in an action when you have the form object readily available with you as a parameter of the execute method? I don't just quite get the need for setting and retrieving the form instance as attributes.
 
Erica Johnson
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your inputs Orton.

Thanks Vicky, for the response. I am new to this and really appreciate your help.

I get the same result in the TestUpdateSubmitAction, null pointer when trying to get that ticketNo;

 
Vicky Vijay
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For Your Quick Reference,

Nested:Iterate Example
 
Erica Johnson
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Vicky. What am I doing wrong here?
 
Vicky Vijay
Ranch Hand
Posts: 125
 
Erica Johnson
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Vicky -- thanks for the help. I am making progress based on your help -- it is appreciated very much.

I finally got my form submission to retain values. But, now I am having an issue with the initialization of an Arraylist. My nested form variables need this initialization, when I’m trying to change more rows on the screen than have been initialized in the form, I get that out of bounds error… When the action is perform and Struts loads the form, it must be resetting it first before it loads the variables from the screen. I was having that index problem for a couple weeks on and off, it probably all boils down to this…

If I want 200 rows on the screen, I have to initialize 200 objects, doesn’t seem very dynamic




Surely, there is a better way to do this. Could you please guide me in the right direction?
reply
    Bookmark Topic Watch Topic
  • New Topic