1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.myfaces.tobago.event;
21
22
23 import org.apache.commons.lang.StringUtils;
24 import org.apache.myfaces.tobago.internal.util.FindComponentUtils;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
27
28 import javax.faces.component.StateHolder;
29 import javax.faces.component.UIComponent;
30 import javax.faces.component.UIComponentBase;
31 import javax.faces.context.FacesContext;
32 import javax.faces.el.ValueBinding;
33 import javax.faces.event.ActionEvent;
34
35
36
37
38
39 @Deprecated
40 public class ValueBindingResetInputActionListener extends AbstractResetInputActionListener implements StateHolder {
41 private static final Logger LOG = LoggerFactory.getLogger(ValueBindingResetInputActionListener.class);
42
43 private ValueBinding clientIdsBinding;
44
45
46
47
48 public ValueBindingResetInputActionListener() {
49 }
50
51 public ValueBindingResetInputActionListener(Object binding) {
52 clientIdsBinding = (ValueBinding) binding;
53 }
54
55 public void processAction(ActionEvent event) {
56 Object obj = clientIdsBinding.getValue(FacesContext.getCurrentInstance());
57 String [] clientIds;
58 if (obj instanceof String[]) {
59 clientIds = (String[]) obj;
60 } else if (obj instanceof String) {
61 clientIds= StringUtils.split((String) obj, ", ");
62 } else {
63 LOG.error("Ignore unknown value of " + obj + " for reset.");
64 return;
65 }
66 for (String clientId : clientIds) {
67 UIComponent component = FindComponentUtils.findComponent(event.getComponent(), clientId);
68 if (component != null) {
69 resetChildren(component);
70 }
71 }
72 }
73
74 public boolean isTransient() {
75 return false;
76 }
77
78 public void restoreState(FacesContext context, Object state) {
79 Object[] values = (Object[]) state;
80 clientIdsBinding = (ValueBinding) UIComponentBase.restoreAttachedState(context, values[0]);
81 }
82
83 public Object saveState(FacesContext context) {
84 Object[] values = new Object[1];
85 values[0] = UIComponentBase.saveAttachedState(context, clientIdsBinding);
86 return values;
87 }
88
89 public void setTransient(boolean newTransientValue) {
90
91 }
92
93 }