• 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

ActionForm variable value null in Action Class

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have a dropdown in my JSP page along with a hidden variable . I select something from the dropdown and Submit the form. In my Action Class, when I try to access the hidden variable value as below :

ClientReportingForm myForm = (ClientReportingForm) form;
strSubAction = myForm.getSubAction();

But this strSubAction is always null. Why is my ActioForm not getting populated when I submit the page.
Please HELP !!

TIA,
Priya
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Priya,
Check that you have a form bean set in your struts config and a name set in your html:form.
 
Priya Jotwani
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jeanee, I have checked and its the same.
 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Priya,
I'm sorry; I read the question wrong. (I mistakenly thought the form was null.)

Can you post the code where you are setting the hidden variable?
 
Priya Jotwani
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jeanne,

I am getting the hidden variable value now beacuse I set that in a Javascript Submit of my page. But now in my Action Class, if I access a ActionForm property(which I had selected in JSP page) , it doesn't gives me anything(not even null).

ClientReportingForm myForm = (ClientReportingForm ) form
String strProductLine = myForm.getProductLine();

WHY

Thanks,
Priya
 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Priya,
When you say you are getting nothing, I assume you are getting an empty string? This often happens if javascript is settting the field to an undefined value.

Try putting an alert() after you set the field in javascript to make sure it is what you are expecting. Also, check that the field name in javascript/html matches the form field name exactly - even in case sensitivity.
reply
    Bookmark Topic Watch Topic
  • New Topic