Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-31-2007, 02:40 PM
Member
 
Join Date: Jul 2007
Posts: 9
arfatkhan is on a distinguished road
ActionForm and Dynaform
Hi Everybody,

What is the difference between ActionForm and DynaFrom.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-31-2007, 03:07 PM
Member
 
Join Date: Jul 2007
Posts: 41
tommy is on a distinguished road
f you are using actionform then you should specify the getter and setter for each components of presentation (jsp ) in to FormBean file.So it is some what complicated one to specify each component for setter and header. To avoid this method we are having DynoActionForm.In struts-config.xml file we can specify the properties.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-31-2007, 03:11 PM
Member
 
Join Date: Jul 2007
Posts: 72
Swamipsn is on a distinguished road
Hi,

ActionForm is a normal FormBean which we have to write a java bean code
using traditional getter() & setter() and need to compile. After the rapid evolution of struts many struts developers feels that writing a java ActionFormfor every form is a tedious task. So DynaActionForm was introduced in the case of DynaActionForm we no need to write any ActionForm with native java bean code.DynaActionForm is too easy to use!!
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 08-01-2007, 12:31 PM
Member
 
Join Date: Jul 2007
Posts: 9
arfatkhan is on a distinguished road
Hi,

I am not clear with, please explain me with a simple example.

Thanks.

Last edited by arfatkhan : 08-01-2007 at 01:18 PM.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 08-10-2007, 12:06 AM
Member
 
Join Date: Jul 2007
Posts: 43
leonard is on a distinguished road
Action form example
Code:
public class AddressForm extends ActionForm { private String name=null; private String address=null; private String emailAddress=null; public void setName(String name){ this.name=name; } public String getName(){ return this.name; } public void setAddress(String address){ this.address=address; } public String getAddress(){ return this.address; } public void setEmailAddress(String emailAddress){ this.emailAddress=emailAddress; } public String getEmailAddress(){ return this.emailAddress; }
If you pay attention in action form you have to write the set and get of every attribute

AddressAction.java
Code:
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.Action; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; public class AddressAction extends Action { public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception{ return mapping.findForward("success"); } }
Now, Dynaform

Code:
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.Action; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.DynaActionForm; import org.apache.struts.action.ActionMessages; import org.apache.struts.action.ActionMessage; public class AddressDynaAction extends Action { public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception{ DynaActionForm addressForm = (DynaActionForm)form; //Create object of ActionMesssages ActionMessages errors = new ActionMessages(); //Check and collect errors if(((String)addressForm.get("name")).equals("")) { errors.add("name",new ActionMessage("error.name.required")); } if(((String)addressForm.get("address")).equals("")) { errors.add("address",new ActionMessage("error.address.required")); } if(((String)addressForm.get("email")).equals("")) { errors.add("email",new ActionMessage("error.emailaddress.required")); } //Saves the error saveErrors(request,errors); //Forward the page if(errors.isEmpty()){ return mapping.findForward("success"); }else{ return mapping.findForward("invalid"); } } }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +3. The time now is 01:13 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org