View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  
20  package org.apache.myfaces.tobago.example.demo;
21  
22  import org.apache.myfaces.tobago.model.SelectItem;
23  
24  import javax.enterprise.context.SessionScoped;
25  import javax.inject.Named;
26  import java.io.Serializable;
27  import java.util.Currency;
28  
29  @Named
30  @SessionScoped
31  public class SelectItemModel implements Serializable {
32  
33    private int number = 3;
34  
35    private Currency currency = Currency.getInstance("JPY");
36    private Currency currency2;
37  
38    private final SelectItem[] availableCurrencies;
39  
40    private final Currency[] availableCurrenciesAsObject;
41  
42    public SelectItemModel() {
43      availableCurrenciesAsObject = new Currency[]{
44          Currency.getInstance("JPY"),
45          Currency.getInstance("TTD"),
46          Currency.getInstance("USD"),
47          Currency.getInstance("EUR")
48      };
49      availableCurrencies = new SelectItem[availableCurrenciesAsObject.length];
50      for (int i = 0; i < availableCurrenciesAsObject.length; i++) {
51        availableCurrencies[i] = new SelectItem(availableCurrenciesAsObject[i]);
52      }
53    }
54  
55    public SelectItem[] getAvailableCurrencies() {
56      return availableCurrencies;
57    }
58  
59    public Currency[] getAvailableCurrenciesAsObject() {
60      return availableCurrenciesAsObject;
61    }
62  
63    public int getNumber() {
64      return number;
65    }
66  
67    public void setNumber(final int number) {
68      this.number = number;
69    }
70  
71    public void setCurrency(final Currency currency) {
72      this.currency = currency;
73    }
74  
75    public Currency getCurrency() {
76      return currency;
77    }
78  
79    public Currency getCurrency2() {
80      return currency2;
81    }
82  
83    public void setCurrency2(final Currency currency2) {
84      this.currency2 = currency2;
85    }
86  
87    public int getTwo() {
88      return 2;
89    }
90  
91    public int getFour() {
92      return 4;
93    }
94  
95    public Currency getUsd() {
96      return Currency.getInstance("USD");
97    }
98  
99    public Currency getEur() {
100     return Currency.getInstance("EUR");
101   }
102 }