2009/05/20 - Apache Shale has been retired.
For more information, please explore the Attic.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.shale.examples.test.dialog.basic;
21
22 import javax.faces.context.FacesContext;
23 import javax.faces.el.ValueBinding;
24
25 import org.apache.shale.dialog.Constants;
26 import org.apache.shale.dialog.DialogContext;
27 import org.apache.shale.dialog.DialogHelper;
28
29 /***
30 * <p>Event handlers for the "PopUp" dialog.</p>
31 */
32 public class Popup {
33
34
35 /***
36 * <p>Cancel the popup dialog.</p>
37 */
38 public String cancel() {
39
40
41 return "cancelled";
42
43 }
44
45
46 /***
47 * <p>Refresh the list of cities for the currently selected state.</p>
48 */
49 public String refresh() {
50
51
52 return null;
53
54 }
55
56
57 /***
58 * <p>Set up the data for this dialog.</p>
59 */
60 public String setup() {
61
62
63 FacesContext context = FacesContext.getCurrentInstance();
64 ValueBinding vb = context.getApplication().createValueBinding("#{dialog.parent.data.state}");
65 String state = (String) vb.getValue(context);
66
67
68 DialogContext dcontext = DialogHelper.getDialogContext(context);
69 PopupData data = (PopupData) dcontext.getData();
70 data.setState(state);
71
72
73 return "success";
74
75 }
76
77
78 /***
79 * <p>Select the row corresponding to this button.</p>
80 */
81 public String select() {
82
83
84 FacesContext context = FacesContext.getCurrentInstance();
85 City city = (City)
86 context.getApplication().getVariableResolver().
87 resolveVariable(context, "city");
88
89
90 ValueBinding vb = null;
91 vb = context.getApplication().createValueBinding("#{dialog.parent.data.city}");
92 vb.setValue(context, city.getCity());
93 vb = context.getApplication().createValueBinding("#{dialog.parent.data.state}");
94 vb.setValue(context, city.getState());
95 vb = context.getApplication().createValueBinding("#{dialog.parent.data.zipCode}");
96 vb.setValue(context, city.getZipCode());
97
98
99 return "finished";
100
101 }
102
103
104 }