package com.javahonk.action;

import com.javahonk.bean.Person;
import com.opensymphony.xwork2.ActionSupport;

public class StrutsSpringAction extends ActionSupport{

	private static final long serialVersionUID = 1L;
	//Value from spring dependency injection
	Person person;
	private String userName;
	private String firstName;
	private String lastName;

	@Override
	public String execute() throws Exception {
		userName = person.userName();
		return ActionSupport.SUCCESS;
	}
	
	@Override
	public void validate() {
		if (null == firstName || firstName.length() == 0)
			addActionError(getText("error.firstName.required"));
		if (null == lastName || lastName.length() == 0)
			addActionError(getText("error.lastName.required"));		
	}

	public Person getPerson() {
		return person;
	}

	public void setPerson(Person person) {
		this.person = person;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}
	
	
	
}
