2009/05/20 - Apache Shale has been retired.

For more information, please explore the Attic.

View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to you under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   *
17   * $Id: Wizard.java 442088 2006-09-11 04:18:44Z craigmcc $
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  }