2009/05/20 - Apache Shale has been retired.
For more information, please explore the Attic.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.shale.examples.test.dialog.scxml;
21
22 import java.io.Serializable;
23 import java.util.ArrayList;
24 import java.util.List;
25
26 import javax.faces.model.SelectItem;
27
28 /***
29 * <p>Model data backing the "popup" dialog.</p>
30 */
31 public class PopupData implements Serializable {
32
33
34 /***
35 * <p>The set of all known cities.</p>
36 */
37 private static City[] cities = new City[] {
38 new City("Beaverton", "OR", "97005"),
39 new City("Beaverton", "OR", "97006"),
40 new City("Beaverton", "OR", "97007"),
41 new City("Beaverton", "OR", "97008"),
42 new City("Beaverton", "OR", "97075"),
43 new City("Beaverton", "OR", "97076"),
44 new City("Beaverton", "OR", "97077"),
45 new City("Beaverton", "OR", "97078"),
46 new City("Lake Oswego", "OR", "97034"),
47 new City("Lake Oswego", "OR", "97035"),
48 new City("Sherwood", "OR", "97140"),
49 new City("Tigard", "OR", "97223"),
50 new City("Tigard", "OR", "97224"),
51 new City("Tigard", "OR", "97281"),
52 new City("Tualatin", "OR", "97062"),
53 new City("West Linn", "OR", "97068"),
54 };
55
56
57 /***
58 * <p>Return a list of cities for the currently selected state.</p>
59 */
60 public City[] getCities() {
61 if (state == null) {
62 return new City[0];
63 }
64 List results = new ArrayList();
65 for (int i = 0; i < cities.length; i++) {
66 if (state.equals(cities[i].getState())) {
67 results.add(cities[i]);
68 }
69 }
70 return (City[]) results.toArray(new City[results.size()]);
71 }
72
73 /***
74 * <p>The currently selected state.</p>
75 */
76 private String state = null;
77
78 public String getState() { return this.state; }
79
80 public void setState(String state) { this.state = state; }
81
82
83 /***
84 * <p>The set of valid states.</p>
85 */
86 private SelectItem[] states = null;
87
88 public SelectItem[] getStates() {
89 if (states == null) {
90 states = new SelectItem[3];
91 states[0] = new SelectItem("CA", "California");
92 states[1] = new SelectItem("OR", "Oregon");
93 states[2] = new SelectItem("WA", "Washington");
94 }
95 return states;
96 }
97
98
99 }