Struts Tutorial -- Code ExamplesDynaActionForm
In this tutorial you will learn how to create Struts DynaActionForm. A regular ActionForm is developed in Java and declared in the struts_config. xml. The JavaBeans properties of a regular ActionForm are created by first defining the instance variable and then adding a getter and setter for that instance variable. A DynaActionForm has no associated Java class. Its JavaBeans properties are created by adding the <form-property> tag in Struts Config file.
For Example : you have a EmpForm and you don't want a java class (EmpForm).
EmpForm has propertis
firstName, lastName, country .
Step 1. Adding DynaActionForm Entry in struts-config.xml
Add the following entry in the struts-config.xml file. The <form-property/> tag is used to define the property for the form bean.
Step 2. Add action mapping in the struts-config.xml file:
Add the following action mapping in the struts-config.xml file:
Step 3. In the Action class.
Step 4. In the JSP page (empform.jsp)
Now in the browser type http://localhost:8080/jsp/empform.jsp
Two major differences between a regular ActionForm and a DynaActionForm.
1) For a DynaActionForm, the type attribute of the form-bean is always org.apache.struts.action.DynaActionForm.
2) A DynaActionForm has no associated Java class. Its JavaBeans properties are created by adding the <form-property> tag in Struts Config file.
SCJP 6.0 Simulator 664+ Questions With Explanations
SCWCD 5.0 Simulator 556+ Questions With Explanations
SCWCD 4.0 Simulator 500+ Questions With Explanations
OCA 10g Simulator 594+ Questions With Explanations
Hiring made easy Harness social networking, employee referrals, Agency portal and Job Portals