DynaActionForm

It enables you to create a “virtual” form bean in Struts configuration file instead of create a real Java form bean class. It can avoid you to create many simple but tedious form bean classes.

<form-bean name="dynaUserForm"  type="org.apache.struts.action.DynaActionForm">
    <form-property name="username" type="java.lang.String"/>
</form-bean>


The different between “DynaActionForm” and “ActionForm”
    DynaActionForm is not required to create a real Java class (just declare in Struts config file), but ActionForm does.
    In DynaActionForm, form validation is implement in Action class, while ActionForm is implement inside its own class.

ActionMessages errors = new ActionMessages();
DynaActionForm userForm = (DynaActionForm)form;

Should you go for DynaActionForm? This feature can save you a lot time to create ActionForm class, but, it has limitation and sometime you have to use a real ActionForm to do certain tasks.



注:摘自http://www.mkyong.com/

你可能感兴趣的:(bean,struts,Go)