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.ParentPackage;
import org.apache.struts2.convention.annotation.Result;

import com.opensymphony.xwork2.ActionSupport;

@ParentPackage("json-default")
public class AutoCompleteAction extends ActionSupport {

	private static final long serialVersionUID = 1L;
	private List<String> jasonList = new ArrayList<String>();	
	private String term;

	@Override
	@Action(value = "/autoCompleteAction", 
		results = { @Result(name = "success", type = "json") })
	public String execute() throws Exception {
		jasonList.addAll(DataForAutoComplete.getName(term));
		return ActionSupport.SUCCESS;
	}	

	public List<String> getJasonList() {
		return jasonList;
	}

	public void setJasonList(List<String> jasonList) {
		this.jasonList = jasonList;
	}

	public String getTerm() {
		return term;
	}

	public void setTerm(String term) {
		this.term = term;
	}
		
}
