ActionForm Beans:- Model Components in Struts Frameworks

ActionForm Beans:- Model Components in Struts Frameworks

Previous Home Next

 

ActionForm beans almost similar to the JavaBeans( ModelBeans) but should be consider a Controller component. Because, that able to transfer data between the Model and View layers.

 In struts framework the ActionForm is generally define by the extending the org.apache.struts.action.ActionForm, Sometime ActionBean also called "form beans". These may be finely-grained objects, so that there is one bean for each form, or coarsely-grained so that one bean serves several forms, or even an entire application.

UsersDetailsAction.java

package com.r4r;

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 UsersDetailsAction extends Action
{
  String username;
  public ActionForward execute(ActionMapping mapping,ActionForm form,
  HttpServletRequest request,HttpServletResponse response) throws Exception{

    return mapping.findForward("success");
  }
  public String getUsername() {
  return username;
  }
  public void setUsername(String username) {
  this.username = username;
  }
}


Previous Home Next