package com.javahonk.action;

import java.util.ArrayList;
import java.util.List;

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;

@Results({
		@Result(name = "error", location = "/iterator.jsp"),
		@Result(name = "input", location = "/iterator.jsp")})
public class IteratorTagExampleAction extends ActionSupport {

	private static final long serialVersionUID = 1L;
	private List<Person> personList = new ArrayList<Person>();
	
	@Override
	@Action(value = "/iteratorTagExampleAction")	
	public String execute() throws Exception {
		
		personList.add(new Person("Java", "Honk", "NY"));
		personList.add(new Person("Ramesh", "Arrepu", "NY"));
		personList.add(new Person("Igor", "Vornovitsky", "NY"));
		personList.add(new Person("Bob", "Sidebottom", "NY"));
		personList.add(new Person("Sunil", "Garg", "NY"));
		personList.add(new Person("Mike", "Lee", "NY"));
		
		return ActionSupport.INPUT;
	}

	public List<Person> getPersonList() {
		return personList;
	}

	public void setPersonList(List<Person> personList) {
		this.personList = personList;
	}	
	
}
