1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package javax.faces.component.behavior;
20
21 import java.util.Collection;
22
23 import javax.faces.component.UIComponent;
24 import javax.faces.context.FacesContext;
25
26
27
28
29 public abstract class ClientBehaviorContext
30 {
31
32
33
34 public static final String BEHAVIOR_SOURCE_PARAM_NAME = "javax.faces.source";
35
36
37
38
39 public static final String BEHAVIOR_EVENT_PARAM_NAME = "javax.faces.behavior.event";
40
41 public static ClientBehaviorContext createClientBehaviorContext(FacesContext context,
42 UIComponent component,
43 String eventName,
44 String sourceId,
45 Collection<Parameter> parameters)
46 {
47
48 if(context == null)
49 {
50 throw new NullPointerException("context argument must not be null");
51 }
52 if(component == null)
53 {
54 throw new NullPointerException("component argument must not be null");
55 }
56 if(eventName == null)
57 {
58 throw new NullPointerException("eventName argument must not be null");
59 }
60
61 return new ClientBehaviorContextImpl(context,component,eventName,sourceId, parameters);
62 }
63
64 public abstract UIComponent getComponent();
65
66 public abstract String getEventName();
67
68 public abstract FacesContext getFacesContext();
69
70 public abstract Collection<Parameter> getParameters();
71
72 public abstract String getSourceId();
73
74
75
76
77 public static class Parameter
78 {
79 private String _name;
80 private Object _value;
81
82 public Parameter(String name, Object value)
83 {
84 if (name == null)
85 {
86 throw new NullPointerException("name");
87 }
88
89 _name = name;
90 _value = value;
91 }
92
93 public String getName()
94 {
95 return _name;
96 }
97
98 public Object getValue()
99 {
100 return _value;
101 }
102 }
103
104 private static final class ClientBehaviorContextImpl extends ClientBehaviorContext
105 {
106 private FacesContext _facesContext;
107 private UIComponent _component;
108 private String _eventName;
109 private String _sourceId;
110 private Collection<ClientBehaviorContext.Parameter> _parameters;
111
112 public ClientBehaviorContextImpl(FacesContext context, UIComponent component, String eventName,
113 String sourceId, Collection<ClientBehaviorContext.Parameter> parameters)
114 {
115 _facesContext = context;
116 _component = component;
117 _eventName = eventName;
118 _sourceId = sourceId;
119 _parameters = parameters;
120 }
121
122 @Override
123 public UIComponent getComponent()
124 {
125 return _component;
126 }
127
128 @Override
129 public String getEventName()
130 {
131 return _eventName;
132 }
133
134 @Override
135 public FacesContext getFacesContext()
136 {
137 return _facesContext;
138 }
139
140 @Override
141 public Collection<Parameter> getParameters()
142 {
143 return _parameters;
144 }
145
146 @Override
147 public String getSourceId()
148 {
149 return _sourceId;
150 }
151 }
152 }