You need to get the form bean data from the servlet, like this: ActionFormBean theFormBean = getServlet().findFormBean(formBeanName);
-- Martin Cooper At 02:02 PM 10/23/01, Stephen Hood wrote: >I am trying to write a generic Action class that I can use with any >ActionForm to add an item to any collection property it may contain. For >example, if I had two ActionForms which each contain a collection (say >"AddressList" and "ProductList"), I could call the same Action with either >form, pass it the name of the collection, and have it add a new item to it, >passing control back to the calling View. > >In order to make it generic, I want the class to figure out the ActionForm >type specified in the mapping, recast the generic ActionForm as the proper >type, and then add another item to the collection indicated by a passed >request attribute. > >To dynamically determine the ActionForm type, I'm trying to use the >equivalent of ActionMapping.getFormClass(), which has been deprecated. The >suggested alternative is to use ActionMapping.getName() and then use it to >look-up the ActionFormBean. It seems the way to do this is to use >ActionFormBeans.findFormBean(String beanName). However, the following code >returns a null ActionFormBean. > > String formBeanName = mapping.getName(); > ActionFormBeans actionFormBeans = new ActionFormBeans(); > ActionFormBean theFormBean = actionFormBeans.findFormBean(formBeanName); > >I assume that my ActionFormBeans object itself is empty and I am not >creating or populating it properly, but I could not find details in the >Struts javadoc. > >Is this the correct approach? > >thanks for any suggestions, >--Steve