All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sun.faces.taglib.jsf_core.SetPropertyActionListenerTag Maven / Gradle / Ivy

Go to download

This is the master POM file for Oracle's Implementation of the JSF 2.2 Specification.

The newest version!
/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
 *
 * The contents of this file are subject to the terms of either the GNU
 * General Public License Version 2 only ("GPL") or the Common Development
 * and Distribution License("CDDL") (collectively, the "License").  You
 * may not use this file except in compliance with the License.  You can
 * obtain a copy of the License at
 * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
 * or packager/legal/LICENSE.txt.  See the License for the specific
 * language governing permissions and limitations under the License.
 *
 * When distributing the software, include this License Header Notice in each
 * file and include the License file at packager/legal/LICENSE.txt.
 *
 * GPL Classpath Exception:
 * Oracle designates this particular file as subject to the "Classpath"
 * exception as provided by Oracle in the GPL Version 2 section of the License
 * file that accompanied this code.
 *
 * Modifications:
 * If applicable, add the following below the License Header, with the fields
 * enclosed by brackets [] replaced by your own identifying information:
 * "Portions Copyright [year] [name of copyright owner]"
 *
 * Contributor(s):
 * If you wish your version of this file to be governed by only the CDDL or
 * only the GPL Version 2, indicate your decision by adding "[Contributor]
 * elects to include this software in this distribution under the [CDDL or GPL
 * Version 2] license."  If you don't indicate a single choice of license, a
 * recipient has the option to distribute your version of this file under
 * either the CDDL, the GPL Version 2 or to extend the choice of license to
 * its licensees as provided above.  However, if you add GPL Version 2 code
 * and therefore, elected the GPL Version 2 license, then the option applies
 * only if the new code is made subject to such option by the copyright
 * holder.
 */

package com.sun.faces.taglib.jsf_core;

import javax.el.ValueExpression;
import javax.faces.component.ActionSource;
import javax.faces.component.UIComponent;
import javax.faces.event.ActionListener;
import javax.faces.webapp.UIComponentClassicTagBase;
import javax.faces.webapp.UIComponentELTag;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;


import com.sun.faces.util.MessageUtils;


/**
 * 

Tag implementation that creates a special {@link ActionListener} instance * and registers it on the {@link ActionSource} associated with our most * immediate surrounding instance of a tag whose implementation class * is a subclass of {@link UIComponentClassicTagBase}. This tag creates no output to * the page currently being created.

*

*

The ActionListener instance created and installed by this tag has the * following behavior and contract.

* *
    * *
  • Only create and register the ActionListener instance * the first time the component for this tag is created
  • * *
  • The "target" and "value" tag attributes are ValueExpression * instances and are stored unevaluated as instance variables of the * listener.
  • * *
  • When the listener executes, call getValue() on the "value" * ValueExpression. Pass the result to a call to setValue() on the * "target" ValueExpression
  • * *
* *

This tag creates no output to the page currently being created. It * is used solely for the side effect of {@link ActionListener} * creation.

*/ public class SetPropertyActionListenerTag extends TagSupport { // ------------------------------------------------------------- Attributes static final long serialVersionUID = 7966883942522780374L; /** *

The target of the value attribute.

*/ private ValueExpression target = null; /** *

The value that is set into the target attribute.

*/ private ValueExpression value = null; /** *

Setter for the target attribute

* * @param target The new class name */ public void setTarget(ValueExpression target) { this.target = target; } /* *

Setter for the value attribute

* * @param value The new value value expression * * @throws JspException if a JSP error occurs */ public void setValue(ValueExpression value) { this.value = value; } // --------------------------------------------------------- Public Methods /** *

Create a new instance of the {@link ActionListener} * class, and register it with the {@link UIComponent} instance associated * with our most immediately surrounding {@link UIComponentClassicTagBase} * instance. The behavior of the {@link ActionListener} must conform * to the class description.

* * @throws JspException if a JSP error occurs */ public int doStartTag() throws JspException { // Locate our parent UIComponentTag UIComponentClassicTagBase tag = UIComponentELTag.getParentUIComponentClassicTagBase(pageContext); if (tag == null) { Object params [] = {this.getClass().getName()}; throw new JspException( MessageUtils.getExceptionMessageString( MessageUtils.NOT_NESTED_IN_FACES_TAG_ERROR_MESSAGE_ID, params)); } // Nothing to do unless this tag created a component if (!tag.getCreated()) { return (SKIP_BODY); } UIComponent component = tag.getComponentInstance(); if (component == null) { throw new JspException( MessageUtils.getExceptionMessageString(MessageUtils.NULL_COMPONENT_ERROR_MESSAGE_ID)); } if (!(component instanceof ActionSource)) { Object params [] = {"setPropertyActionListener", "javax.faces.component.ActionSource"}; throw new JspException( MessageUtils.getExceptionMessageString( MessageUtils.NOT_NESTED_IN_TYPE_TAG_ERROR_MESSAGE_ID, params)); } ActionListener handler = new SetPropertyActionListenerImpl(target, value); ((ActionSource) component).addActionListener(handler); return (SKIP_BODY); } /** *

Release references to any acquired resources. */ public void release() { this.value = null; this.target = null; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy