1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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 }