package roseindia.action;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.interceptor.ServletRequestAware;

import roseindia.model.StudentDetails;

import com.opensymphony.xwork2.ActionSupport;

public class OGNLAction extends ActionSupport implements ServletRequestAware {

	private HttpServletRequest request;
	private String studentname;
	private int age;

	public String getStudentname() {
		return studentname;
	}

	public void setStudentname(String studentname) {
		this.studentname = studentname;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	public void setServletRequest(HttpServletRequest request) {
		this.request = request;

	}

	public HttpServletRequest getServletRequest() {
		return request;
	}

	public String execute() throws Exception {

		if (studentname.equals("none")) {
			this.addActionError("Please Select name...");
			return ERROR;
		}
		StudentDetails bean = new StudentDetails();
		bean.setStudentname(studentname);
		bean.setAge(age);
		request.setAttribute("bean", bean);
		return SUCCESS;
	}

}
