01: package org.apache.struts2.showcase.ajax;
02:
03: import java.util.ArrayList;
04: import java.util.List;
05:
06: import com.opensymphony.xwork2.ActionSupport;
07:
08: public class AutocompleterExampleAction extends ActionSupport {
09: private String select;
10: private List<String> options = new ArrayList<String>();
11:
12: private static final long serialVersionUID = -8481638176160014396L;
13:
14: public String execute() throws Exception {
15: if ("fruits".equals(select)) {
16: options.add("apple");
17: options.add("banana");
18: options.add("grape");
19: options.add("pear");
20: } else if ("colors".equals(select)) {
21: options.add("red");
22: options.add("green");
23: options.add("blue");
24: }
25: return SUCCESS;
26: }
27:
28: public String getSelect() {
29: return select;
30: }
31:
32: public void setSelect(String select) {
33: this .select = select;
34: }
35:
36: public List<String> getOptions() {
37: return options;
38: }
39: }
|