package com.javahonk.action;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.validator.annotations.RequiredStringValidator;

@Results({
	   @Result(name="success", location="/WEB-INF/jsp/success.jsp"),
	   @Result(name="input", location="/WEB-INF/jsp/welcome.jsp"),
	   @Result(name="error", location="/WEB-INF/jsp/welcome.jsp")
	})
public class StrutsAction extends ActionSupport {

	private static final long serialVersionUID = 1L;
	private String firstName;
	private String lastName;
	private String message;

	@Override
	@Action(value="/strutsAction")
	public String execute() throws Exception {
		message = "Your entered input values are:";
		return ActionSupport.SUCCESS;
	}

	public String getFirstName() {
		return firstName;
	}

	@RequiredStringValidator(message = "First Name is required!")
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	@RequiredStringValidator(message = "Last Name is required!")
	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

}
