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.basic; |
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 | |
|
30 | |
|
31 | 0 | public class PopupData implements Serializable { |
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | 0 | 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 | |
|
59 | |
|
60 | |
public City[] getCities() { |
61 | 0 | if (state == null) { |
62 | 0 | return new City[0]; |
63 | |
} |
64 | 0 | List results = new ArrayList(); |
65 | 0 | for (int i = 0; i < cities.length; i++) { |
66 | 0 | if (state.equals(cities[i].getState())) { |
67 | 0 | results.add(cities[i]); |
68 | |
} |
69 | |
} |
70 | 0 | return (City[]) results.toArray(new City[results.size()]); |
71 | |
} |
72 | |
|
73 | |
|
74 | |
|
75 | |
|
76 | 0 | private String state = null; |
77 | |
|
78 | 0 | public String getState() { return this.state; } |
79 | |
|
80 | 0 | public void setState(String state) { this.state = state; } |
81 | |
|
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | 0 | private SelectItem[] states = null; |
87 | |
|
88 | |
public SelectItem[] getStates() { |
89 | 0 | if (states == null) { |
90 | 0 | states = new SelectItem[3]; |
91 | 0 | states[0] = new SelectItem("CA", "California"); |
92 | 0 | states[1] = new SelectItem("OR", "Oregon"); |
93 | 0 | states[2] = new SelectItem("WA", "Washington"); |
94 | |
} |
95 | 0 | return states; |
96 | |
} |
97 | |
|
98 | |
|
99 | |
} |