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 public static ClientBehaviorContext createClientBehaviorContext(FacesContext context,
33 UIComponent component,
34 String eventName,
35 String sourceId,
36 Collection<Parameter> parameters)
37 {
38
39 if(context == null)
40 {
41 throw new NullPointerException("context argument must not be null");
42 }
43 if(component == null)
44 {
45 throw new NullPointerException("component argument must not be null");
46 }
47 if(eventName == null)
48 {
49 throw new NullPointerException("eventName argument must not be null");
50 }
51
52 return new ClientBehaviorContextImpl(context,component,eventName,sourceId, parameters);
53 }
54
55 public abstract UIComponent getComponent();
56
57 public abstract String getEventName();
58
59 public abstract FacesContext getFacesContext();
60
61 public abstract Collection<Parameter> getParameters();
62
63 public abstract String getSourceId();
64
65
66
67
68 public static class Parameter
69 {
70 private String _name;
71 private Object _value;
72
73 public Parameter(String name, Object value)
74 {
75 if (name == null)
76 {
77 throw new NullPointerException("name");
78 }
79
80 _name = name;
81 _value = value;
82 }
83
84 public String getName()
85 {
86 return _name;
87 }
88
89 public Object getValue()
90 {
91 return _value;
92 }
93 }
94
95 private static final class ClientBehaviorContextImpl extends ClientBehaviorContext
96 {
97 private FacesContext _facesContext;
98 private UIComponent _component;
99 private String _eventName;
100 private String _sourceId;
101 private Collection<ClientBehaviorContext.Parameter> _parameters;
102
103 public ClientBehaviorContextImpl(FacesContext context, UIComponent component, String eventName,
104 String sourceId, Collection<ClientBehaviorContext.Parameter> parameters)
105 {
106 _facesContext = context;
107 _component = component;
108 _eventName = eventName;
109 _sourceId = sourceId;
110 _parameters = parameters;
111 }
112
113 @Override
114 public UIComponent getComponent()
115 {
116 return _component;
117 }
118
119 @Override
120 public String getEventName()
121 {
122 return _eventName;
123 }
124
125 @Override
126 public FacesContext getFacesContext()
127 {
128 return _facesContext;
129 }
130
131 @Override
132 public Collection<Parameter> getParameters()
133 {
134 return _parameters;
135 }
136
137 @Override
138 public String getSourceId()
139 {
140 return _sourceId;
141 }
142 }
143 }