1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.myfaces.view.facelets.el;
20
21 import java.io.Externalizable;
22 import java.io.IOException;
23 import java.io.ObjectInput;
24 import java.io.ObjectOutput;
25
26 import javax.el.ELContext;
27 import javax.el.ValueExpression;
28 import javax.faces.FacesWrapper;
29 import javax.faces.context.FacesContext;
30 import javax.faces.view.Location;
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47 public class LocationValueExpression extends ValueExpression
48 implements FacesWrapper<ValueExpression>, Externalizable
49 {
50
51 private static final long serialVersionUID = -5636849184764526288L;
52
53
54 Location location;
55 ValueExpression delegate;
56
57 public LocationValueExpression()
58 {
59 super();
60 }
61
62 public LocationValueExpression(Location location, ValueExpression delegate)
63 {
64 this.location = location;
65 this.delegate = delegate;
66 }
67
68 public Location getLocation()
69 {
70 return location;
71 }
72
73 @Override
74 public Class<?> getExpectedType()
75 {
76 return delegate.getExpectedType();
77 }
78
79 @Override
80 public Class<?> getType(ELContext context)
81 {
82 FacesContext facesContext = (FacesContext) context.getContext(FacesContext.class);
83 CompositeComponentELUtils.saveCompositeComponentForResolver(facesContext, location);
84 try
85 {
86 return delegate.getType(context);
87 }
88 finally
89 {
90 CompositeComponentELUtils.removeCompositeComponentForResolver(facesContext);
91 }
92 }
93
94 @Override
95 public Object getValue(ELContext context)
96 {
97 FacesContext facesContext = (FacesContext) context.getContext(FacesContext.class);
98 CompositeComponentELUtils.saveCompositeComponentForResolver(facesContext, location);
99 try
100 {
101 return delegate.getValue(context);
102 }
103 finally
104 {
105 CompositeComponentELUtils.removeCompositeComponentForResolver(facesContext);
106 }
107 }
108
109 @Override
110 public boolean isReadOnly(ELContext context)
111 {
112 FacesContext facesContext = (FacesContext) context.getContext(FacesContext.class);
113 CompositeComponentELUtils.saveCompositeComponentForResolver(facesContext, location);
114 try
115 {
116 return delegate.isReadOnly(context);
117 }
118 finally
119 {
120 CompositeComponentELUtils.removeCompositeComponentForResolver(facesContext);
121 }
122 }
123
124 @Override
125 public void setValue(ELContext context, Object value)
126 {
127 FacesContext facesContext = (FacesContext) context.getContext(FacesContext.class);
128 CompositeComponentELUtils.saveCompositeComponentForResolver(facesContext, location);
129 try
130 {
131 delegate.setValue(context, value);
132 }
133 finally
134 {
135 CompositeComponentELUtils.removeCompositeComponentForResolver(facesContext);
136 }
137 }
138
139 @Override
140 public boolean equals(Object obj)
141 {
142 return delegate.equals(obj);
143 }
144
145 @Override
146 public String getExpressionString()
147 {
148 return delegate.getExpressionString();
149 }
150
151 @Override
152 public int hashCode()
153 {
154 return delegate.hashCode();
155 }
156
157 @Override
158 public boolean isLiteralText()
159 {
160 return delegate.isLiteralText();
161 }
162
163 public ValueExpression getWrapped()
164 {
165 return delegate;
166 }
167
168 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
169 {
170 this.delegate = (ValueExpression) in.readObject();
171 this.location = (Location) in.readObject();
172 }
173
174 public void writeExternal(ObjectOutput out) throws IOException
175 {
176 out.writeObject(this.delegate);
177 out.writeObject(this.location);
178 }
179 }