Initialize DynaActionForm


Web tier: servlets, JSP, Web frameworks: Initialize DynaActionForm

  1. Initialize DynaActionForm (2 messages)

    Hi all
    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

    Threaded Messages (2)

  2. Re:Initialize DynaActionForm[ Go to top ]


    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. :-)

    Piotr Maj
  3. Re:Initialize DynaActionForm[ Go to top ]

    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.

    Piotr Maj