1600 PMP mock questions 1400 CAPM mock questions 800 SCJP 6 mock questions 600 OCAJP 7 mock questions 590 OCPJP 7 mock questions 556 SCWCD 5 mock questions 500 OCEJWCD 6 mock questions pdfDownload (java,struts, hibernet etc)

Struts Tutorials

Q. What is DynaActionForm ? and How you can retrive the value which is set in the JSP Page in case of DynaActionForm ?

DynaActionForm is specialized subclass of ActionForm that allows the creation of form beans with dynamic sets of properties,
without requiring the developer to create a Java class for each type of form bean.
DynaActionForm eliminates the need of FormBean class and now the form bean definition can be written into the struts-config.xml file. So, i
t makes the FormBean declarative and this helps the programmer to reduce the development time.

For Example : you have a EmpForm and you don't want a java class (EmpForm).
EmpForm has propertis
firstName, lastName, country

In the struts-config.xml file , declare the form bean
<form-bean name="EmpForm"
<form-property name="firstName" type="java.lang.String"/>
<form-property name="lastName" type="java.lang.String"/>
<form-property name="country" type="java.lang.String" />

Add action mapping in the struts-config.xml file:

<action path="/saveEmp" type="com.techfaq.action.EmpSaveAction"

<forward name="success" path="/jsp/success.jsp"/>
<forward name="failure" path="/jsp/error.jsp" />


In the Action class.
public class EmpSaveAction extends Action
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception{

DynaActionForm empForm = (DynaActionForm)form;
// this is the way you can retrive the value which is set in the JSP Page
String firstName = (String)empForm.get("firstName");
String lastName = (String)empForm.get("lastName");
return mapping.findForward("success");

In the JSP page
<html:text property="firstName" size="30" maxlength="30"/>
<html:text property="lastName" size="30" maxlength="30"/>

Reviews and Comments

PMP, CAPM, PMI is a registered certification mark of the Project Management Institute, Inc

Copyright © www.techfaq360.com 2019

About US | Contact US | Privacy Policy | Terms and Conditions  | Website disclaimer  | Cancellation and Refund Policy  | Shipping & Delivery Policy