Well we have a system for doing lookups that is triggered through a custom tag in the jsp just after the <html:form> and is configured by an xml description. The actual lookups can be made directly against our service ejbs or from front end only 'helper' objects (which can also do some caching if required). something along these lines (ignore names in these, for example only!) <bean-setup name="userForm"> <property-lookup name="departments" lookup="myHelper.getDepartments"> <param value="internal" type="java.lang.String"/> </property-lookup> <bean-setup>
all our forms are derived off a derivation of ActionForm that adds a map called lookup, that the looked up values are added into. sometimes some of the lookups need information from the form to which they are attached to get the correct list, in this case we have something like: <bean-setup name="userForm"> <property-lookup name="employees" lookup="ejb_user.getEmployees"> <param property="userId" /> </property-lookup> <bean-setup> which takes the property userId from the userform and passes it into getEmployees. The lookup code is also clever enough to spot if the function takes an HttpServletRequest and automagically appends this to the method calls. this is enough to deal with everything we need at the moment. Ian >>> [EMAIL PROTECTED] 09/30/02 02:22pm >>> 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]>