1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.apache.myfaces.trinidad.event;
20
21 import javax.faces.component.UIComponent;
22
23 import javax.faces.event.FacesEvent;
24 import javax.faces.event.FacesListener;
25
26 /**
27 * Event delivered when a renderer-specific attribute has been
28 * changed as a result of user interaction. This event gives
29 * advanced <code>Renderers</code> a chance to inform a generic
30 * {@link org.apache.myfaces.trinidad.component.UIXComponent} that some portion of it's appearance
31 * has been manipulated. For example, a "splitter" panel renderer
32 * could indicate that the proportions of the splitter have changed.
33 * <p>
34 * <code>AttributeChangeEvents</code> are not delivered in response
35 * to programmatic manipulation of a renderer-specific attribute.
36 * They must be explicitly queued by a <code>Renderer</code> when
37 * it detects that the user had manipulated the component. Developers
38 * should not abuse this event as a one-size-fits-all generic
39 * component event. When a generic component event changes - like
40 * "value" or "disclosed", deliver a strongly-typed component event
41 * such as <code>ValueChangeEvent</code> or {@link DisclosureEvent}.
42 *
43 * @version $Name: $ ($Revision: adfrt/faces/adf-faces-api/src/main/java/oracle/adf/view/faces/event/AttributeChangeEvent.java#0 $) $Date: 10-nov-2005.19:08:59 $
44 */
45 public class AttributeChangeEvent extends FacesEvent
46 {
47 public AttributeChangeEvent(
48 UIComponent source,
49 String attribute,
50 Object oldValue,
51 Object newValue)
52 {
53 super(source);
54 _attribute = attribute;
55 _oldValue = oldValue;
56 _newValue = newValue;
57 }
58
59 public String getAttribute()
60 {
61 return _attribute;
62 }
63
64 public Object getOldValue()
65 {
66 return _oldValue;
67 }
68
69 public Object getNewValue()
70 {
71 return _newValue;
72 }
73
74 @Override
75 public void processListener(FacesListener listener)
76 {
77 ((AttributeChangeListener) listener).processAttributeChange(this);
78 }
79
80 @Override
81 public boolean isAppropriateListener(FacesListener listener)
82 {
83 return (listener instanceof AttributeChangeListener);
84 }
85
86 @Override
87 public String toString()
88 {
89 StringBuffer sb = new StringBuffer();
90 sb.append(getClass().getName());
91 sb.append("[attribute=");
92 sb.append(getAttribute());
93 sb.append(",component=");
94 sb.append(getComponent());
95 sb.append(",oldValue=");
96 sb.append(getOldValue());
97 sb.append(",newValue=");
98 sb.append(getNewValue());
99 sb.append(']');
100 return sb.toString();
101 }
102
103 private final String _attribute;
104 private final Object _oldValue;
105 private final Object _newValue;
106 private static final long serialVersionUID = 1L;
107 }