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.taglib.core; 20 21 import javax.el.ValueExpression; 22 import javax.faces.component.EditableValueHolder; 23 import javax.faces.event.ValueChangeListener; 24 25 import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFJspAttribute; 26 import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFJspTag; 27 28 /** 29 * Adds the specified ValueChangeListener to the nearest parent UIComponent (which is expected to be a UIInput 30 * component). 31 * <p> 32 * Whenever the form containing the parent UIComponent is submitted, an instance of the specified type is created. If 33 * the submitted value from the component is different from the component's current value then a ValueChangeEvent is 34 * queued. When the ValueChangeEvent is processed (at end of the validate phase for non-immediate components, or at end 35 * of the apply-request-values phase for immediate components) the object's processValueChange method is invoked. 36 * </p> 37 * <p> 38 * Unless otherwise specified, all attributes accept static values or EL expressions. 39 * </p> 40 * 41 * @author Manfred Geiler (latest modification by $Author$) 42 * @version $Revision$ $Date$ 43 */ 44 @JSFJspTag(name = "f:valueChangeListener", bodyContent = "empty") 45 public class ValueChangeListenerTag extends GenericListenerTag<EditableValueHolder, ValueChangeListener> 46 { 47 private static final long serialVersionUID = 2155190261951046892L; 48 49 public ValueChangeListenerTag() 50 { 51 super(EditableValueHolder.class); 52 } 53 54 @Override 55 protected void addListener(EditableValueHolder editableValueHolder, ValueChangeListener valueChangeListener) 56 { 57 editableValueHolder.addValueChangeListener(valueChangeListener); 58 } 59 60 @Override 61 protected ValueChangeListener createDelegateListener(ValueExpression type, ValueExpression binding) 62 { 63 return new DelegateValueChangeListener(type, binding); 64 } 65 66 /** 67 * The name of a Java class that implements ValueChangeListener. 68 */ 69 @Override 70 @JSFJspAttribute(className="javax.el.ValueExpression", 71 deferredValueType="java.lang.String") 72 public void setType(ValueExpression type) 73 { 74 super.setType(type); 75 } 76 77 /** 78 * Value binding expression that evaluates to an implementation of the javax.faces.event.ValueChangeListener 79 * interface. 80 */ 81 @Override 82 @JSFJspAttribute(className="javax.el.ValueExpression", 83 deferredValueType="javax.faces.event.ValueChangeListener") 84 public void setBinding(ValueExpression binding) 85 { 86 super.setBinding(binding); 87 } 88 }