Hi All,

I am trying to find a way to populate a DynaActionForm after the form has been
submitted. For example, I have the following:

public class MyBean implements serializable {
   public String name, address;

   public MyBean() {
      name = new String();
      address = new String();
   }

   public String getName() {
      return this.name;
   }

   public void setName(String name) {
      this.name = name;
   }

   public String getAddress() {
      return this.address;
   }

   public void setAddress(String address) {
      this.address = address;
   }
}

public class MyAction extends BaseDispatchAction {
   public ActionForward save(ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception 
   {
      MyBean myBean = (MyBean)((DynaActionForm)form).get("MyBean");
      // do some processing
      ((DynaActionForm)form).set("myBean", myBean);
      return mapping.findForward(IConstants.SUCCESS_KEY);
   }
}

<struts-config>
   <form-beans>
      <form-bean name="myForm" dynamic="true"
                 type="org.apache.struts.action.DynaActionForm">
         <form-property name="myBean" type="com.test.MyBean"/>
      </form-bean>
   </form-beans>
   <action-mappings>
      <action path="/MyAction"
         type="com.test.MyAction"
         parameter="method"
         name="myForm"
         scope="request">
         <forward name="Success" path="my.page" />
      </action>
   </action-mappings>
</struts-config>

# JSP Page
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<html>
<head>
<title>Test</title>
</head>
<body>
<html:form action="/MyAction" method="post">
Hidden Test
<input type="submit" name="submit" value="submit"/>
<html:hidden property="????" value="myname"/>
<html:hidden property="????" value="myaddress"/>
</html:form>
</body>
</html>

I am not sure what to put in the "property" attribute in the html:hidden area so
that it will populate MyBean in my DynaActionForm property. Please keep in mind
that this is just a sample and I need to use the DynaActionForm and not extend
the MyBean class to ActionForm. Any help or suggestion is much appreciated.

Thanks,
~K

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to