Your example: private void prepopulateForm( ... ) { // copy properties from the DTO to the form if ( form != null && contact != null ) { DynaActionForm dvForm = (DynaActionForm) form; BeanUtils.copyProperties( dvForm, contact ); //manually deal with prospectName since it's called prospectNameOrId on the form dvForm.set( "prospectNameOrId", contact.getProspectName() ); } }
Does not work for me. I get this: ERROR [com.bay4.jsp] [org.apache.taglibs.log.LoggerTag] 2003-12-19 09:30:41,285 http80-Processor2 -- java.lang.IllegalArgumentException: No destination bean specified at org.apache.commons.beanutils.BeanUtils.copyProperties(BeanUtils.java:220) at com.bay4.struts.action.UserDetailAction.myPerform(UserDetailAction.java:57) at com.bay4.struts.action.BaseAction.execute(BaseAction.java:78) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274 Here is a snippet of my code: HttpSession session = request.getSession(false); User user = (User)session.getAttribute(Const.USER); DynaActionForm dvForm = (DynaActionForm) form; BeanUtils.copyProperties( dvForm, user ); return mapping.findForward("showdetail"); I have this defined in my struts-config.xml: <form-bean name="userEditForm" type="org.apache.struts.validator.DynaValidatorForm"> <form-property name="id" type="java.lang.String" initial=""/> <form-property name="firstName" type="java.lang.String" initial=""/> <form-property name="lastName" type="java.lang.String" initial=""/> <form-property name="email" type="java.lang.String" initial=""/> <form-property name="phoneNumber" type="java.lang.String" initial=""/> <form-property name="password" type="java.lang.String" initial=""/> <form-property name="passwordRetype" type="java.lang.String" initial=""/> <form-property name="companyId" type="java.lang.String" initial=""/> <form-property name="roles" type="java.lang.String" initial=""/> </form-bean> Plus more stuff in validation.xml. Won't go into all that. How is the connection made between what I have defined in my struts config and the copyProperties method. At that point, I have not even accessed the form. The form object is just an ActionForm. I'm missing something here. Jim Kennedy IT Consultant Mobile Phone: 813-503-1484 ----------------------------------------------------- ----- Original Message ----- From: "Wendy Smoak" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]>; "Jim Kennedy" <[EMAIL PROTECTED]> Sent: Friday, December 19, 2003 10:03 AM Subject: RE: DynaValidatorForm and setting initial value for the html-el:text tag > From: Jim Kennedy [mailto:[EMAIL PROTECTED] > Yes, this is on the right track, but how do I create a > DynaValidatorForm before it is actually used inside a form? > I don't think you can cast down like that. > I understand how it is created "after" I submit > the form, but not before I submit the form. Look at the signature of the execute method. The form bean gets created before execute is called, and passed into the method. The code I posted is from a working app, I only deleted the try/catch and some logging. Configure logging and turn it up to debug, Struts and the other Jakarta components are very verbose. Or run it in a debugger and see what really happens-- I learned more in 2 hours with Jswat than I had in months of reading and experimentation. -- Wendy Smoak Application Systems Analyst, Sr. ASU IA Information Resources Management