I have to instantiate a DynaActionForm/DynaValidatorForm, before it is used in page. My need is to pre-compilate some of it's property, so that the user does not have to fill in.
I try with the code:
DynaActionForm dynaForm = new DynaActionForm();
I get a NullpointerException after set method!!
Does anyone can help me??
Thanks Aldo Funicelli
a DynaForm need undelying dynaclass to work. If you want to initialize DynaForm
in struts action try something like this:
ModuleConfig module = context.getMapping().getModuleConfig();
FormBeanConfig formBeanConfig = module.findFormBeanConfig("formNameDefinedIn:struts-config.xml");
DynaActionFormClass dynaClass = DynaActionFormClass.createDynaActionFormClass(formBeanConfig);
DynaValidatorForm form = (DynaValidatorForm) dynaClass.newInstance();
this should help. At least it work form me. :-)
ModuleConfig module = context.getMapping().getModuleConfig();Sorry, this context is something specific for my project. In plain struts action
you get a mapping pointer in execute() method.