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 javax.enterprise.context.RequestScoped;
23  import javax.inject.Named;
24  import java.io.Serializable;
25  import java.util.ArrayList;
26  import java.util.List;
27  
28  @RequestScoped
29  @Named
30  public class SelectManyCheckboxController implements Serializable {
31  
32    private List<String> animals = new ArrayList<>();
33    private List<String> numbers = new ArrayList<>();
34  
35    private SolarObject[] selectedTerrestrialPlanet;
36    private SolarObject[] selectedGiantPlanet;
37  
38    public List getAnimals() {
39      return animals;
40    }
41  
42    public void setAnimals(final List<String> animals) {
43      this.animals = animals;
44    }
45  
46    public String getAnimal() {
47      String retValue = "";
48      for (final String s : animals) {
49        retValue = retValue.concat(s + " ");
50      }
51      return retValue;
52    }
53  
54    public List<String> getNumbers() {
55      return numbers;
56    }
57  
58    public void setNumbers(final List<String> numbers) {
59      this.numbers = numbers;
60    }
61  
62    public int getResult() {
63      int result = 0;
64      for (final String number : numbers) {
65        result += Integer.valueOf(number);
66      }
67      return result;
68    }
69  
70    public SolarObject[] getSelectedTerrestrialPlanet() {
71      return selectedTerrestrialPlanet;
72    }
73  
74    public void setSelectedTerrestrialPlanet(SolarObject[] selectedTerrestrialPlanet) {
75      this.selectedTerrestrialPlanet = selectedTerrestrialPlanet;
76    }
77  
78    public SolarObject[] getSelectedGiantPlanet() {
79      return selectedGiantPlanet;
80    }
81  
82    public void setSelectedGiantPlanet(SolarObject[] selectedGiantPlanet) {
83      this.selectedGiantPlanet = selectedGiantPlanet;
84    }
85  }