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 import org.apache.myfaces.tobago.internal.util.FindComponentUtils;
23
24 import javax.faces.component.StateHolder;
25 import javax.faces.component.UIComponent;
26 import javax.faces.context.FacesContext;
27 import javax.faces.event.ActionEvent;
28 import java.util.Collection;
29
30 public class ResetInputActionListener extends AbstractResetInputActionListener implements StateHolder {
31
32 private String [] clientIds;
33
34 public ResetInputActionListener() {
35 }
36
37 public ResetInputActionListener(String[] clientIds) {
38 this.clientIds = clientIds;
39 }
40
41 public ResetInputActionListener(Collection<String> clientIds) {
42 this.clientIds = clientIds.toArray(new String[clientIds.size()]);
43 }
44
45 public void processAction(ActionEvent event) {
46 for (String clientId : clientIds) {
47 UIComponent component = FindComponentUtils.findComponent(event.getComponent(), clientId);
48 if (component != null) {
49 resetChildren(component);
50 }
51 }
52 }
53
54 public boolean isTransient() {
55 return false;
56 }
57
58 public void setTransient(boolean newTransientValue) {
59
60 }
61
62 public void restoreState(FacesContext context, Object state) {
63 Object[] values = (Object[]) state;
64 clientIds = (String[]) values[0];
65 }
66
67 public Object saveState(FacesContext context) {
68 Object[] values = new Object[1];
69 values[0] = clientIds;
70 return values;
71 }
72 }