• 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

Form does not carry data

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there.

I'm developing a new small project using struts. I have created a Form hierarchy like this:

ActionForm <- BaseForm <- CathegoriesForm
ActionForm <- BaseForm <- EstimationsForm



BaseForm has a property called "nick". After succeeding at Login with the user "johndoe", the property nick gets this value. Thus, when I get into CathegoriesAction, CathegoriesForm.getNick() gets the value "johndoe", too.

But when I get inside the execute method of EstimationsForm, nick gets a null value. I've declared both Forms in the same way at struts-config.xml, coded them similar... Please take a look at my code:








The struts-config.xml:



I'm forwarding from a jsp using an <html:link/> tag but the reference says "URL rewriting will be applied automatically, to maintain session state in the absence of cookies", I can't understand why the attribute is getting null value. Can anybody help me? Thanks in advance
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem appears to be in the signature of your reset method in the BaseForm and its subclasses. If you expect Struts to call this method, it must have exactly the following signature:
 
Roberto Lopez Lopez
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Merril for your reply:

I've done as you said, but didn't succeed. Finally I had to put the nick as an attribute into session, so I avoid this problem.

I think this problem can be due to not being the same form instance... I noticed cathegoriesForm didn't run, too (I had a setNick sentence in the execute that I had forgot). Another reason could be the scope, but I wrote scope="session" into the login action-bean on struts-config.xml and didn't success...

What do you think? Setting the nick as a session attribute is not a reasonable solution... I'm sure there's something wrong here.

Thanks for your support!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic