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.RequestScoped;
25  import javax.inject.Named;
26  import java.io.Serializable;
27  import java.util.ArrayList;
28  import java.util.List;
29  
30  @RequestScoped
31  @Named
32  public class SelectManyListboxController implements Serializable {
33  
34    private List<String> celestials = new ArrayList<>();
35    private SelectItem[] deserts;
36    private List<String> selectedDeserts = new ArrayList<>();
37  
38    public SelectManyListboxController() {
39      deserts = new SelectItem[]{
40              new SelectItem("Antarctic Desert"),
41              new SelectItem("Arctic"),
42              new SelectItem("Sahara"),
43              new SelectItem("Arabian Desert"),
44              new SelectItem("Gobi Desert")
45      };
46    }
47  
48    public List<String> getCelestials() {
49      return celestials;
50    }
51  
52    public void setCelestials(final List<String> celestials) {
53      this.celestials = celestials;
54    }
55  
56    public String getCelestial() {
57      String retValue = "";
58      for (final String s : celestials) {
59        retValue = retValue.concat(s);
60      }
61      return retValue;
62    }
63  
64    public SelectItem[] getDeserts() {
65      return deserts;
66    }
67  
68    public List<String> getSelectedDeserts() {
69      return selectedDeserts;
70    }
71  
72    public void setSelectedDeserts(final List<String> selectedDeserts) {
73      this.selectedDeserts = selectedDeserts;
74    }
75  }