| 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
internet detective
Marshal
Joined: May 26, 2003
Posts: 23635
|
|
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]
Certs: SCEA Part 1, Part 2 & 3 & Core Spring 3, OCAJP
|
 |
Priya Jotwani
Ranch Hand
Joined: Oct 30, 2002
Posts: 53
|
|
Jeanee, I have checked and its the same.
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 23635
|
|
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
internet detective
Marshal
Joined: May 26, 2003
Posts: 23635
|
|
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.
|
 |
 |
|
|
subject: ActionForm variable value null in Action Class
|
|
|