| Author |
Problem with using DynaValidatorForm, is it possible to do it??
|
ashish kulkarni
Ranch Hand
Joined: Aug 15, 2002
Posts: 130
|
|
Hi, I am trying to do the following and i get null pointer exception, DynaValidatorForm PL1820UpdateForm = new DynaValidatorForm(); PL1820UpdateForm.set("input1", "This is test"); And my form definiation in struts-config is <form-bean name="PL1820UpdateForm" dynamic="true" type="org.apache.struts.validator.DynaValidatorForm"> <form-property name="input1" type="java.lang.String" /> </form-bean> The error i get it following java.lang.NullPointerException [1/16/03 19:30:24:908 EST] 311dffa9 SystemErr R at org.apache.struts.action.DynaActionForm.getDynaProperty(DynaActionForm.java:551) [1/16/03 19:30:24:908 EST] 311dffa9 SystemErr R at org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:365) [1/16/03 19:30:24:908 EST] 311dffa9 SystemErr R at com.pfizer.maps.action.sop.PL1820DispatchAction.getData(PL1820DispatchAction.java:197) [1/16/03 19:30:24:908 EST] 311dffa9 SystemErr R at com.pfizer.maps.action.sop.PL1820DispatchAction.change(PL1820DispatchAction.java:145) Need help
|
A$HI$H
|
 |
Venkatesh Rangarajan
Greenhorn
Joined: Jan 06, 2003
Posts: 14
|
|
hi a$hi$h, By the stack trace I could guess that the code is in an action class. And as far as I know its the Struts and Validator framework which are responsibile for instantiating and initializing the form (especially a dyna form). So instead of instantiating the form object you can just cast and refer to the ActionForm instance passed to the Action class method. As I had the source code I saw that there is additional information (like the DynaClass) in the Dyna Form which I assume is populated by the framework and that is why you are getting the NullPointerException. hope it helps, venky
|
 |
ashish kulkarni
Ranch Hand
Joined: Aug 15, 2002
Posts: 130
|
|
Hi, What i am trying to do it the following, I have a DispatchAction class which is called from a jsp ( and passed user) then i need to popluate a Bean (Action or Dyna) and put it in request and pass it to jsp, so the jsp will display using taglib the fields populated in bean, I have defined a form-bean in struts-config.xml file and want to use the same structure and create a dynamic bean instead of defining a bean My form-bean defination is as follows <form-bean name="PL1820UpdateForm" dynamic="true" type="org.apache.struts.validator.DynaValidatorForm"> <form-property name="input1" type="java.lang.String" /> </form-bean> So how do i poplate it in my DispatchAction and pass it to jsp Ashish
|
 |
Krishna M. Mishra
Greenhorn
Joined: Mar 16, 2010
Posts: 1
|
|
Hi Ashish,
Ensure that your stuts-config.xml have this entry (inside the action tag for your Action-class):
<action ...
...
name="PL1820UpdateForm"
...
>
...
</action>
In real, form-bean tag's name attribute must have the same value as the action tag's name attribute's value.
I think, rest is fine.
Regards,
Krishna
|
--
Thanks & Regards,
Krishna Mohan Mishra
SCJP
|
 |
 |
|
|
subject: Problem with using DynaValidatorForm, is it possible to do it??
|
|
|