I was wondering what the overall philosophy is in the Struts Users community
in regards to pre-populating action forms? I sent a message out late last
week asking for help on how to manually instantiate and pre-populate an
action form (prior to forwarding to a JS) in Struts 1.1. That's when I
realized this may be considered bad practice. Here are some comments I
received:
Eddie Bush:
"No, no. Actions/Forms have a contract -- the form 'will' be created.
You should not take this upon yourself. What you need to do is pre-face
the page with a 'populate' action. Expect it to be there"
James Turner:
I can still point to cases where you need to manually pre-populate.
For example, if you have multiple forms on a single JSP page, you either
need to pre-populate the forms manually, or you'd have to daisy-chain a
bunch of actions together, each one of which was responsible for
pre-populating a single form. This seems clumsy to me. Maybe what we need
is an authoritative way (i.e., an API) to instantiate DynaForms.
What are others doing here? BTW, if manually pre-populating an action form
is acceptable, does it make sense to create a method in the "RequestUtils"
package making this
easy to do for a DynaForm (Struts 1.1). For example (code provided by James
Turner):
ApplicationConfig appConfig =
(ApplicationConfig)request.getAttribute(Action.APPLICATION_KEY);
FormBeanConfig formBeanConfig =
appConfig.findFormBeanConfig("myDynaActionForm");
String beanType = formBeanConfig.getType();
DynaActionForm bean;
DynaActionFormClass formClass =
DynaActionFormClass.createDynaActionFormClass(formBeanConfig);
return (DynaActionForm) formClass.newInstance();
Thanks! JOHN
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>