aspose file tools*
The moose likes Struts and the fly likes ActionForm variable value null in Action Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "ActionForm variable value null in Action Class" Watch "ActionForm variable value null in Action Class" New topic
Author

ActionForm variable value null in Action Class

Priya Jotwani
Ranch Hand

Joined: Oct 30, 2002
Posts: 53
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

Joined: May 26, 2003
Posts: 31079
    
163

Priya,
Check that you have a form bean set in your struts config and a name set in your html:form.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Priya Jotwani
Ranch Hand

Joined: Oct 30, 2002
Posts: 53
Jeanee, I have checked and its the same.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31079
    
163

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

Joined: Oct 30, 2002
Posts: 53
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

Joined: May 26, 2003
Posts: 31079
    
163

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ActionForm variable value null in Action Class