1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package javax.faces.component; |
20 | |
|
21 | |
import java.util.ArrayList; |
22 | |
import java.util.List; |
23 | |
import javax.el.ValueExpression; |
24 | |
import javax.faces.FacesException; |
25 | |
import javax.faces.application.FacesMessage; |
26 | |
import javax.faces.context.FacesContext; |
27 | |
import javax.faces.convert.Converter; |
28 | |
import javax.faces.convert.ConverterException; |
29 | |
import javax.faces.el.EvaluationException; |
30 | |
import javax.faces.el.MethodBinding; |
31 | |
import javax.faces.event.AbortProcessingException; |
32 | |
import javax.faces.event.FacesEvent; |
33 | |
import javax.faces.event.ValueChangeEvent; |
34 | |
import javax.faces.event.ValueChangeListener; |
35 | |
import javax.faces.render.Renderer; |
36 | |
import javax.faces.validator.Validator; |
37 | |
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFComponent; |
38 | |
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFListener; |
39 | |
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFProperty; |
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
@JSFComponent(defaultRendererType = "javax.faces.Text") |
50 | |
public class UIInput extends UIOutput implements EditableValueHolder |
51 | |
{ |
52 | |
public static final String COMPONENT_TYPE = "javax.faces.Input"; |
53 | |
public static final String COMPONENT_FAMILY = "javax.faces.Input"; |
54 | |
|
55 | |
public static final String CONVERSION_MESSAGE_ID = "javax.faces.component.UIInput.CONVERSION"; |
56 | |
public static final String REQUIRED_MESSAGE_ID = "javax.faces.component.UIInput.REQUIRED"; |
57 | |
public static final String UPDATE_MESSAGE_ID = "javax.faces.component.UIInput.UPDATE"; |
58 | |
private static final String ERROR_HANDLING_EXCEPTION_LIST = "org.apache.myfaces.errorHandling.exceptionList"; |
59 | |
|
60 | 0 | private static final Validator[] EMPTY_VALIDATOR_ARRAY = new Validator[0]; |
61 | |
|
62 | |
private boolean _immediate; |
63 | |
private boolean _immediateSet; |
64 | |
|
65 | |
private Object _submittedValue; |
66 | 0 | private boolean _localValueSet = false; |
67 | |
|
68 | 0 | private boolean _valid = true; |
69 | |
|
70 | |
private boolean _required; |
71 | |
private boolean _requiredSet; |
72 | |
|
73 | |
private String _converterMessage; |
74 | |
private String _requiredMessage; |
75 | |
private String _validatorMessage; |
76 | |
|
77 | |
private MethodBinding _validator; |
78 | |
private List<Validator> _validatorList; |
79 | |
|
80 | |
private MethodBinding _valueChangeListener; |
81 | |
|
82 | |
|
83 | |
|
84 | |
|
85 | |
public UIInput() |
86 | 0 | { |
87 | 0 | setRendererType("javax.faces.Text"); |
88 | 0 | } |
89 | |
|
90 | |
@Override |
91 | |
public String getFamily() |
92 | |
{ |
93 | 0 | return COMPONENT_FAMILY; |
94 | |
} |
95 | |
|
96 | |
|
97 | |
|
98 | |
|
99 | |
|
100 | |
|
101 | |
|
102 | |
|
103 | |
public void setValue(Object value) |
104 | |
{ |
105 | 0 | setLocalValueSet(true); |
106 | 0 | super.setValue(value); |
107 | 0 | } |
108 | |
|
109 | |
|
110 | |
|
111 | |
|
112 | |
|
113 | |
|
114 | |
|
115 | |
|
116 | |
|
117 | |
public Object getValue() |
118 | |
{ |
119 | 0 | if (isLocalValueSet()) return super.getLocalValue(); |
120 | 0 | return super.getValue(); |
121 | |
} |
122 | |
|
123 | |
|
124 | |
|
125 | |
|
126 | |
|
127 | |
|
128 | |
|
129 | |
|
130 | |
|
131 | |
|
132 | |
|
133 | |
|
134 | |
|
135 | |
|
136 | |
|
137 | |
|
138 | |
|
139 | |
|
140 | |
public void processDecodes(FacesContext context) |
141 | |
{ |
142 | 0 | if (context == null) |
143 | |
{ |
144 | 0 | throw new NullPointerException("context"); |
145 | |
} |
146 | |
try |
147 | |
{ |
148 | 0 | setCachedFacesContext(context); |
149 | 0 | if (!isRendered()) |
150 | |
{ |
151 | |
return; |
152 | |
} |
153 | |
} |
154 | |
finally |
155 | |
{ |
156 | 0 | setCachedFacesContext(null); |
157 | 0 | } |
158 | 0 | super.processDecodes(context); |
159 | |
try |
160 | |
{ |
161 | 0 | setCachedFacesContext(context); |
162 | 0 | if (isImmediate()) |
163 | |
{ |
164 | |
try |
165 | |
{ |
166 | 0 | validate(context); |
167 | |
} |
168 | 0 | catch (RuntimeException e) |
169 | |
{ |
170 | 0 | context.renderResponse(); |
171 | 0 | throw e; |
172 | 0 | } |
173 | 0 | if (!isValid()) |
174 | |
{ |
175 | 0 | context.renderResponse(); |
176 | |
} |
177 | |
} |
178 | |
} |
179 | |
finally |
180 | |
{ |
181 | 0 | setCachedFacesContext(null); |
182 | 0 | } |
183 | 0 | } |
184 | |
|
185 | |
public void processValidators(FacesContext context) |
186 | |
{ |
187 | 0 | if (context == null) |
188 | |
{ |
189 | 0 | throw new NullPointerException("context"); |
190 | |
} |
191 | |
try |
192 | |
{ |
193 | 0 | setCachedFacesContext(context); |
194 | 0 | if (!isRendered()) |
195 | |
{ |
196 | |
return; |
197 | |
} |
198 | |
} |
199 | |
finally |
200 | |
{ |
201 | 0 | setCachedFacesContext(null); |
202 | 0 | } |
203 | |
|
204 | 0 | super.processValidators(context); |
205 | |
|
206 | |
try |
207 | |
{ |
208 | 0 | setCachedFacesContext(context); |
209 | 0 | if (!isImmediate()) |
210 | |
{ |
211 | |
try |
212 | |
{ |
213 | 0 | validate(context); |
214 | |
} |
215 | 0 | catch (RuntimeException e) |
216 | |
{ |
217 | 0 | context.renderResponse(); |
218 | 0 | throw e; |
219 | 0 | } |
220 | 0 | if (!isValid()) |
221 | |
{ |
222 | 0 | context.renderResponse(); |
223 | |
} |
224 | |
} |
225 | |
} |
226 | |
finally |
227 | |
{ |
228 | 0 | setCachedFacesContext(null); |
229 | 0 | } |
230 | 0 | } |
231 | |
|
232 | |
public void processUpdates(FacesContext context) |
233 | |
{ |
234 | 0 | if (context == null) |
235 | |
{ |
236 | 0 | throw new NullPointerException("context"); |
237 | |
} |
238 | |
try |
239 | |
{ |
240 | 0 | setCachedFacesContext(context); |
241 | 0 | if (!isRendered()) |
242 | |
{ |
243 | |
return; |
244 | |
} |
245 | |
} |
246 | |
finally |
247 | |
{ |
248 | 0 | setCachedFacesContext(null); |
249 | 0 | } |
250 | |
|
251 | 0 | super.processUpdates(context); |
252 | |
|
253 | |
try |
254 | |
{ |
255 | 0 | setCachedFacesContext(context); |
256 | |
try |
257 | |
{ |
258 | 0 | updateModel(context); |
259 | |
} |
260 | 0 | catch (RuntimeException e) |
261 | |
{ |
262 | 0 | context.renderResponse(); |
263 | 0 | throw e; |
264 | 0 | } |
265 | 0 | if (!isValid()) |
266 | |
{ |
267 | 0 | context.renderResponse(); |
268 | |
} |
269 | |
} |
270 | |
finally |
271 | |
{ |
272 | 0 | setCachedFacesContext(null); |
273 | 0 | } |
274 | 0 | } |
275 | |
|
276 | |
public void decode(FacesContext context) |
277 | |
{ |
278 | |
|
279 | 0 | setValid(true); |
280 | 0 | super.decode(context); |
281 | 0 | } |
282 | |
|
283 | |
public void broadcast(FacesEvent event) throws AbortProcessingException |
284 | |
{ |
285 | |
|
286 | 0 | super.broadcast(event); |
287 | |
|
288 | |
|
289 | 0 | if (event instanceof ValueChangeEvent) |
290 | |
{ |
291 | |
|
292 | 0 | MethodBinding valueChangeListenerBinding = getValueChangeListener(); |
293 | 0 | if (valueChangeListenerBinding != null) |
294 | |
{ |
295 | |
try |
296 | |
{ |
297 | 0 | valueChangeListenerBinding.invoke(getFacesContext(), |
298 | |
new Object[] |
299 | |
{ event }); |
300 | |
} |
301 | 0 | catch (EvaluationException e) |
302 | |
{ |
303 | 0 | Throwable cause = e.getCause(); |
304 | 0 | if (cause != null |
305 | |
&& cause instanceof AbortProcessingException) |
306 | |
{ |
307 | 0 | throw (AbortProcessingException) cause; |
308 | |
} |
309 | |
else |
310 | |
{ |
311 | 0 | throw e; |
312 | |
} |
313 | 0 | } |
314 | |
} |
315 | |
} |
316 | 0 | } |
317 | |
|
318 | |
public void updateModel(FacesContext context) |
319 | |
{ |
320 | 0 | if (!isValid()) |
321 | |
{ |
322 | 0 | return; |
323 | |
} |
324 | 0 | if (!isLocalValueSet()) |
325 | |
{ |
326 | 0 | return; |
327 | |
} |
328 | 0 | ValueExpression expression = getValueExpression("value"); |
329 | 0 | if (expression == null) |
330 | |
{ |
331 | 0 | return; |
332 | |
} |
333 | |
|
334 | |
try |
335 | |
{ |
336 | 0 | expression.setValue(context.getELContext(), getLocalValue()); |
337 | 0 | setValue(null); |
338 | 0 | setLocalValueSet(false); |
339 | |
} |
340 | 0 | catch (Exception e) |
341 | |
{ |
342 | 0 | context.getExternalContext().log(e.getMessage(), e); |
343 | 0 | _MessageUtils.addErrorMessage(context, this, UPDATE_MESSAGE_ID, |
344 | |
new Object[] |
345 | |
{ _MessageUtils.getLabel(context, this) }); |
346 | 0 | setValid(false); |
347 | |
|
348 | |
|
349 | |
|
350 | |
|
351 | |
|
352 | |
|
353 | 0 | queueExceptionInRequest(context, expression, e); |
354 | 0 | } |
355 | 0 | } |
356 | |
|
357 | |
|
358 | |
|
359 | |
|
360 | |
|
361 | |
|
362 | |
private void queueExceptionInRequest(FacesContext context, |
363 | |
ValueExpression expression, Exception e) |
364 | |
{ |
365 | 0 | List li = (List) context.getExternalContext().getRequestMap().get(ERROR_HANDLING_EXCEPTION_LIST); |
366 | 0 | if (null == li) |
367 | |
{ |
368 | 0 | li = new ArrayList(); |
369 | 0 | context.getExternalContext().getRequestMap().put(ERROR_HANDLING_EXCEPTION_LIST, li); |
370 | |
} |
371 | 0 | li.add(new FacesException( |
372 | |
"Exception while setting value for expression : " |
373 | |
+ expression.getExpressionString() |
374 | |
+ " of component with path : " |
375 | |
+ _ComponentUtils.getPathToComponent(this), e)); |
376 | 0 | } |
377 | |
|
378 | |
protected void validateValue(FacesContext context, Object convertedValue) |
379 | |
{ |
380 | 0 | boolean empty = convertedValue == null |
381 | |
|| (convertedValue instanceof String && ((String) convertedValue) |
382 | |
.length() == 0); |
383 | |
|
384 | 0 | if (isRequired() && empty) |
385 | |
{ |
386 | 0 | if (getRequiredMessage() != null) |
387 | |
{ |
388 | 0 | String requiredMessage = getRequiredMessage(); |
389 | 0 | context.addMessage(this.getClientId(context), new FacesMessage( |
390 | |
FacesMessage.SEVERITY_ERROR, requiredMessage, |
391 | |
requiredMessage)); |
392 | 0 | } |
393 | |
else |
394 | |
{ |
395 | 0 | _MessageUtils.addErrorMessage(context, this, |
396 | |
REQUIRED_MESSAGE_ID, new Object[] |
397 | |
{ _MessageUtils.getLabel(context, this) }); |
398 | |
} |
399 | 0 | setValid(false); |
400 | 0 | return; |
401 | |
} |
402 | |
|
403 | 0 | if (!empty) |
404 | |
{ |
405 | 0 | _ComponentUtils.callValidators(context, this, convertedValue); |
406 | |
} |
407 | |
|
408 | 0 | } |
409 | |
|
410 | |
|
411 | |
|
412 | |
|
413 | |
|
414 | |
|
415 | |
|
416 | |
|
417 | |
|
418 | |
|
419 | |
|
420 | |
|
421 | |
|
422 | |
|
423 | |
|
424 | |
|
425 | |
|
426 | |
|
427 | |
|
428 | |
|
429 | |
|
430 | |
|
431 | |
|
432 | |
|
433 | |
|
434 | |
|
435 | |
|
436 | |
public void validate(FacesContext context) |
437 | |
{ |
438 | 0 | if (context == null) |
439 | 0 | throw new NullPointerException("context"); |
440 | |
|
441 | |
try |
442 | |
{ |
443 | |
|
444 | 0 | Object submittedValue = getSubmittedValue(); |
445 | 0 | if (submittedValue == null) |
446 | 0 | return; |
447 | |
|
448 | 0 | Object convertedValue = getConvertedValue(context, submittedValue); |
449 | |
|
450 | 0 | if (!isValid()) |
451 | 0 | return; |
452 | |
|
453 | 0 | validateValue(context, convertedValue); |
454 | |
|
455 | 0 | if (!isValid()) |
456 | 0 | return; |
457 | |
|
458 | 0 | Object previousValue = getValue(); |
459 | 0 | setValue(convertedValue); |
460 | 0 | setSubmittedValue(null); |
461 | 0 | if (compareValues(previousValue, convertedValue)) |
462 | |
{ |
463 | 0 | queueEvent(new ValueChangeEvent(this, previousValue, |
464 | |
convertedValue)); |
465 | |
} |
466 | |
} |
467 | 0 | catch (Exception ex) |
468 | |
{ |
469 | 0 | throw new FacesException( |
470 | |
"Exception while validating component with path : " |
471 | |
+ _ComponentUtils.getPathToComponent(this), ex); |
472 | 0 | } |
473 | |
|
474 | 0 | } |
475 | |
|
476 | |
|
477 | |
|
478 | |
|
479 | |
|
480 | |
|
481 | |
|
482 | |
|
483 | |
|
484 | |
|
485 | |
|
486 | |
|
487 | |
|
488 | |
|
489 | |
|
490 | |
|
491 | |
|
492 | |
|
493 | |
|
494 | |
|
495 | |
|
496 | |
|
497 | |
protected Object getConvertedValue(FacesContext context, Object submittedValue) |
498 | |
{ |
499 | |
try |
500 | |
{ |
501 | 0 | Renderer renderer = getRenderer(context); |
502 | 0 | if (renderer != null) |
503 | |
{ |
504 | 0 | return renderer |
505 | |
.getConvertedValue(context, this, submittedValue); |
506 | |
} |
507 | 0 | else if (submittedValue instanceof String) |
508 | |
{ |
509 | 0 | Converter converter = _SharedRendererUtils |
510 | |
.findUIOutputConverter(context, this); |
511 | 0 | if (converter != null) |
512 | |
{ |
513 | 0 | return converter.getAsObject(context, this, |
514 | |
(String) submittedValue); |
515 | |
} |
516 | |
} |
517 | |
} |
518 | 0 | catch (ConverterException e) |
519 | |
{ |
520 | 0 | String converterMessage = getConverterMessage(); |
521 | 0 | if (converterMessage != null) |
522 | |
{ |
523 | 0 | context.addMessage(getClientId(context), new FacesMessage( |
524 | |
FacesMessage.SEVERITY_ERROR, converterMessage, |
525 | |
converterMessage)); |
526 | |
} |
527 | |
else |
528 | |
{ |
529 | 0 | FacesMessage facesMessage = e.getFacesMessage(); |
530 | 0 | if (facesMessage != null) |
531 | |
{ |
532 | 0 | context.addMessage(getClientId(context), facesMessage); |
533 | |
} |
534 | |
else |
535 | |
{ |
536 | 0 | _MessageUtils.addErrorMessage(context, this, |
537 | |
CONVERSION_MESSAGE_ID, new Object[] |
538 | |
{ _MessageUtils.getLabel(context, this) }); |
539 | |
} |
540 | |
} |
541 | 0 | setValid(false); |
542 | 0 | } |
543 | 0 | return submittedValue; |
544 | |
} |
545 | |
|
546 | |
protected boolean compareValues(Object previous, Object value) |
547 | |
{ |
548 | 0 | return previous == null ? (value != null) : (!previous.equals(value)); |
549 | |
} |
550 | |
|
551 | |
|
552 | |
|
553 | |
|
554 | |
public void resetValue() |
555 | |
{ |
556 | 0 | setSubmittedValue(null); |
557 | 0 | setValue(null); |
558 | 0 | setLocalValueSet(false); |
559 | 0 | setValid(true); |
560 | 0 | } |
561 | |
|
562 | |
|
563 | |
|
564 | |
|
565 | |
|
566 | |
|
567 | |
|
568 | |
|
569 | |
|
570 | |
@JSFProperty |
571 | |
public boolean isImmediate() |
572 | |
{ |
573 | 0 | if (_immediateSet) |
574 | |
{ |
575 | 0 | return _immediate; |
576 | |
} |
577 | 0 | ValueExpression expression = getValueExpression("immediate"); |
578 | 0 | if (expression != null) |
579 | |
{ |
580 | 0 | return (Boolean) expression.getValue(getFacesContext() |
581 | |
.getELContext()); |
582 | |
} |
583 | 0 | return false; |
584 | |
} |
585 | |
|
586 | |
public void setImmediate(boolean immediate) |
587 | |
{ |
588 | 0 | this._immediate = immediate; |
589 | 0 | this._immediateSet = true; |
590 | 0 | } |
591 | |
|
592 | |
|
593 | |
|
594 | |
|
595 | |
|
596 | |
|
597 | |
|
598 | |
|
599 | |
|
600 | |
|
601 | |
|
602 | |
|
603 | |
@JSFProperty(defaultValue = "false") |
604 | |
public boolean isRequired() |
605 | |
{ |
606 | 0 | if (_requiredSet) |
607 | |
{ |
608 | 0 | return _required; |
609 | |
} |
610 | 0 | ValueExpression expression = getValueExpression("required"); |
611 | 0 | if (expression != null) |
612 | |
{ |
613 | 0 | return (Boolean) expression.getValue(getFacesContext() |
614 | |
.getELContext()); |
615 | |
} |
616 | 0 | return false; |
617 | |
} |
618 | |
|
619 | |
public void setRequired(boolean required) |
620 | |
{ |
621 | 0 | this._required = required; |
622 | 0 | this._requiredSet = true; |
623 | 0 | } |
624 | |
|
625 | |
|
626 | |
|
627 | |
|
628 | |
|
629 | |
|
630 | |
|
631 | |
@JSFProperty |
632 | |
public String getConverterMessage() |
633 | |
{ |
634 | 0 | if (_converterMessage != null) |
635 | |
{ |
636 | 0 | return _converterMessage; |
637 | |
} |
638 | 0 | ValueExpression expression = getValueExpression("converterMessage"); |
639 | 0 | if (expression != null) |
640 | |
{ |
641 | 0 | return (String) expression.getValue(getFacesContext() |
642 | |
.getELContext()); |
643 | |
} |
644 | 0 | return null; |
645 | |
} |
646 | |
|
647 | |
public void setConverterMessage(String converterMessage) |
648 | |
{ |
649 | 0 | this._converterMessage = converterMessage; |
650 | 0 | } |
651 | |
|
652 | |
|
653 | |
|
654 | |
|
655 | |
|
656 | |
|
657 | |
@JSFProperty |
658 | |
public String getRequiredMessage() |
659 | |
{ |
660 | 0 | if (_requiredMessage != null) |
661 | |
{ |
662 | 0 | return _requiredMessage; |
663 | |
} |
664 | 0 | ValueExpression expression = getValueExpression("requiredMessage"); |
665 | 0 | if (expression != null) |
666 | |
{ |
667 | 0 | return (String) expression.getValue(getFacesContext() |
668 | |
.getELContext()); |
669 | |
} |
670 | 0 | return null; |
671 | |
} |
672 | |
|
673 | |
public void setRequiredMessage(String requiredMessage) |
674 | |
{ |
675 | 0 | this._requiredMessage = requiredMessage; |
676 | 0 | } |
677 | |
|
678 | |
|
679 | |
|
680 | |
|
681 | |
|
682 | |
|
683 | |
|
684 | |
|
685 | |
|
686 | |
|
687 | |
|
688 | |
|
689 | |
|
690 | |
|
691 | |
|
692 | |
@JSFProperty(stateHolder = true, returnSignature = "void", methodSignature = "javax.faces.context.FacesContext,javax.faces.component.UIComponent,java.lang.Object") |
693 | |
public MethodBinding getValidator() |
694 | |
{ |
695 | 0 | if (_validator != null) |
696 | |
{ |
697 | 0 | return _validator; |
698 | |
} |
699 | 0 | ValueExpression expression = getValueExpression("validator"); |
700 | 0 | if (expression != null) |
701 | |
{ |
702 | 0 | return (MethodBinding) expression.getValue(getFacesContext() |
703 | |
.getELContext()); |
704 | |
} |
705 | 0 | return null; |
706 | |
} |
707 | |
|
708 | |
|
709 | |
|
710 | |
|
711 | |
|
712 | |
public void setValidator(MethodBinding validator) |
713 | |
{ |
714 | 0 | this._validator = validator; |
715 | 0 | } |
716 | |
|
717 | |
|
718 | |
public void addValidator(Validator validator) |
719 | |
{ |
720 | 0 | if (validator == null) |
721 | 0 | throw new NullPointerException("validator"); |
722 | 0 | if (_validatorList == null) |
723 | 0 | _validatorList = new ArrayList<Validator>(); |
724 | |
|
725 | 0 | _validatorList.add(validator); |
726 | 0 | } |
727 | |
|
728 | |
|
729 | |
public void removeValidator(Validator validator) |
730 | |
{ |
731 | 0 | if (validator == null || _validatorList == null) |
732 | 0 | return; |
733 | |
|
734 | 0 | _validatorList.remove(validator); |
735 | 0 | } |
736 | |
|
737 | |
|
738 | |
public Validator[] getValidators() |
739 | |
{ |
740 | 0 | return _validatorList == null ? EMPTY_VALIDATOR_ARRAY : _validatorList |
741 | |
.toArray(new Validator[_validatorList.size()]); |
742 | |
} |
743 | |
|
744 | |
|
745 | |
|
746 | |
|
747 | |
@JSFProperty |
748 | |
public String getValidatorMessage() |
749 | |
{ |
750 | 0 | if (_validatorMessage != null) |
751 | |
{ |
752 | 0 | return _validatorMessage; |
753 | |
} |
754 | 0 | ValueExpression expression = getValueExpression("validatorMessage"); |
755 | 0 | if (expression != null) |
756 | |
{ |
757 | 0 | return (String) expression.getValue(getFacesContext() |
758 | |
.getELContext()); |
759 | |
} |
760 | 0 | return null; |
761 | |
} |
762 | |
|
763 | |
public void setValidatorMessage(String validatorMessage) |
764 | |
{ |
765 | 0 | this._validatorMessage = validatorMessage; |
766 | 0 | } |
767 | |
|
768 | |
|
769 | |
|
770 | |
|
771 | |
|
772 | |
|
773 | |
|
774 | |
|
775 | |
|
776 | |
|
777 | |
|
778 | |
|
779 | |
@JSFProperty(stateHolder = true, returnSignature = "void", methodSignature = "javax.faces.event.ValueChangeEvent") |
780 | |
public MethodBinding getValueChangeListener() |
781 | |
{ |
782 | 0 | if (_valueChangeListener != null) |
783 | |
{ |
784 | 0 | return _valueChangeListener; |
785 | |
} |
786 | 0 | ValueExpression expression = getValueExpression("valueChangeListener"); |
787 | 0 | if (expression != null) |
788 | |
{ |
789 | 0 | return (MethodBinding) expression.getValue(getFacesContext() |
790 | |
.getELContext()); |
791 | |
} |
792 | 0 | return null; |
793 | |
} |
794 | |
|
795 | |
|
796 | |
|
797 | |
|
798 | |
|
799 | |
|
800 | |
public void setValueChangeListener(MethodBinding valueChangeListener) |
801 | |
{ |
802 | 0 | this._valueChangeListener = valueChangeListener; |
803 | 0 | } |
804 | |
|
805 | |
|
806 | |
|
807 | |
|
808 | |
|
809 | |
@JSFProperty(defaultValue = "true", tagExcluded = true) |
810 | |
public boolean isValid() |
811 | |
{ |
812 | 0 | return _valid; |
813 | |
} |
814 | |
|
815 | |
public void setValid(boolean valid) |
816 | |
{ |
817 | 0 | this._valid = valid; |
818 | 0 | } |
819 | |
|
820 | |
|
821 | |
|
822 | |
|
823 | |
|
824 | |
|
825 | |
@JSFProperty(defaultValue = "false", tagExcluded = true) |
826 | |
public boolean isLocalValueSet() |
827 | |
{ |
828 | 0 | return _localValueSet; |
829 | |
} |
830 | |
|
831 | |
public void setLocalValueSet(boolean localValueSet) |
832 | |
{ |
833 | 0 | this._localValueSet = localValueSet; |
834 | 0 | } |
835 | |
|
836 | |
|
837 | |
|
838 | |
|
839 | |
|
840 | |
|
841 | |
|
842 | |
|
843 | |
|
844 | |
|
845 | |
@JSFProperty(tagExcluded = true) |
846 | |
public Object getSubmittedValue() |
847 | |
{ |
848 | 0 | return _submittedValue; |
849 | |
} |
850 | |
|
851 | |
public void setSubmittedValue(Object submittedValue) |
852 | |
{ |
853 | 0 | this._submittedValue = submittedValue; |
854 | 0 | } |
855 | |
|
856 | |
public void addValueChangeListener(ValueChangeListener listener) |
857 | |
{ |
858 | 0 | addFacesListener(listener); |
859 | 0 | } |
860 | |
|
861 | |
public void removeValueChangeListener(ValueChangeListener listener) |
862 | |
{ |
863 | 0 | removeFacesListener(listener); |
864 | 0 | } |
865 | |
|
866 | |
|
867 | |
|
868 | |
|
869 | |
|
870 | |
@JSFListener(event="javax.faces.event.ValueChangeEvent") |
871 | |
public ValueChangeListener[] getValueChangeListeners() |
872 | |
{ |
873 | 0 | return (ValueChangeListener[]) getFacesListeners(ValueChangeListener.class); |
874 | |
} |
875 | |
|
876 | |
@Override |
877 | |
public Object saveState(FacesContext facesContext) |
878 | |
{ |
879 | 0 | Object[] values = new Object[14]; |
880 | 0 | values[0] = super.saveState(facesContext); |
881 | 0 | values[1] = _immediate; |
882 | 0 | values[2] = _immediateSet; |
883 | 0 | values[3] = _required; |
884 | 0 | values[4] = _requiredSet; |
885 | 0 | values[5] = _converterMessage; |
886 | 0 | values[6] = _requiredMessage; |
887 | 0 | values[7] = saveAttachedState(facesContext, _validator); |
888 | 0 | values[8] = saveAttachedState(facesContext, _validatorList); |
889 | 0 | values[9] = _validatorMessage; |
890 | 0 | values[10] = saveAttachedState(facesContext, _valueChangeListener); |
891 | 0 | values[11] = _valid; |
892 | 0 | values[12] = _localValueSet; |
893 | 0 | values[13] = _submittedValue; |
894 | |
|
895 | 0 | return values; |
896 | |
} |
897 | |
|
898 | |
@Override |
899 | |
public void restoreState(FacesContext facesContext, Object state) |
900 | |
{ |
901 | 0 | Object[] values = (Object[]) state; |
902 | 0 | super.restoreState(facesContext, values[0]); |
903 | 0 | _immediate = (Boolean) values[1]; |
904 | 0 | _immediateSet = (Boolean) values[2]; |
905 | 0 | _required = (Boolean) values[3]; |
906 | 0 | _requiredSet = (Boolean) values[4]; |
907 | 0 | _converterMessage = (String) values[5]; |
908 | 0 | _requiredMessage = (String) values[6]; |
909 | 0 | _validator = (MethodBinding) restoreAttachedState(facesContext, |
910 | |
values[7]); |
911 | 0 | _validatorList = (List<Validator>) restoreAttachedState(facesContext, |
912 | |
values[8]); |
913 | 0 | _validatorMessage = (String) values[9]; |
914 | 0 | _valueChangeListener = (MethodBinding) restoreAttachedState( |
915 | |
facesContext, values[10]); |
916 | 0 | _valid = (Boolean) values[11]; |
917 | 0 | _localValueSet = (Boolean) values[12]; |
918 | 0 | _submittedValue = values[13]; |
919 | 0 | } |
920 | |
} |