The Model:- System State & Business Logic JavaBeans

The Model:- System State & Business Logic JavaBeans

Previous Home Next

 

A model represents appication's data and state and contains the business logic for accessing and manipulating that data.where data that is part of the persistent state of the application. ActionForm bean represents the Model state and not at a persistent level.The controller can accessed model services effecting a change in the model state.The model notifies the view when a state change occurs in the model.


 Set of one or more JavaBeans represents the internal state of the system .Entity Enterprise JavaBeans (Entity EJBs) are also commonly used to represent internal state. The actions are part of Controller. In struts1.3 we are using model, the model represent data and business logic which are present in JavaBean and Action class in this tutorial we are see the format of JavaBean which are following and format of Action class also which are following

HelloForm.java

package com.r4r.struts;
import org.apache.struts.action.ActionForm;
@SuppressWarnings("serial")
public class HelloForm extends ActionForm {
	private String userName;
	private String userDOB;
	private String userCourse;
	private String userCity;
	private String userState;
	private String userCountry;
	private String userPhone;
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public String getUserDOB() {
		return userDOB;
	}
	public void setUserDOB(String userDOB) {
		this.userDOB = userDOB;
	}
	public String getUserCourse() {
		return userCourse;
	}
	public void setUserCourse(String userCourse) {
		this.userCourse = userCourse;
	}
	public String getUserCity() {
		return userCity;
	}
	public void setUserCity(String userCity) {
		this.userCity = userCity;
	}
	public String getUserState() {
		return userState;
	}
	public void setUserState(String userState) {
		this.userState = userState;
	}
	public String getUserCountry() {
		return userCountry;
	}
	public void setUserCountry(String userCountry) {
		this.userCountry = userCountry;
	}
	public String getUserPhone() {
		return userPhone;
	}
	public void setUserPhone(String userPhone) {
		this.userPhone = userPhone;
	}

}

HelloAction.java


package com.r4r.struts;

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 HelloAction extends Action {
public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response){
return mapping.findForward("success");
	}

}


Previous Home Next