• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ActionForm variable value null in Action Class

 
Priya Jotwani
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • 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
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34656
366
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Jeanee, I have checked and its the same.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34656
366
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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
Marshal
Posts: 34656
366
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic