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

org.ajax4jsf.tag.AjaxSupportHandler Maven / Gradle / Ivy

Go to download

Ajax4jsf is an open source extension to the JavaServer Faces standard that adds AJAX capability to JSF applications without requiring the writing of any JavaScript.

The newest version!
/**
 * Licensed under the Common Development and Distribution License,
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.sun.com/cddl/
 *   
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
 * implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */

package org.ajax4jsf.tag;

import java.io.IOException;

import javax.el.ELException;
import javax.faces.FacesException;
import javax.faces.component.UIComponent;
import javax.faces.component.UIComponentBase;

import org.ajax4jsf.taglib.ajax.AjaxSupportTag;

import com.sun.facelets.FaceletContext;
import com.sun.facelets.FaceletException;
import com.sun.facelets.tag.TagAttribute;
import com.sun.facelets.tag.TagHandler;
import com.sun.facelets.tag.jsf.ComponentConfig;

/**
 * "proxy" class for creating UIAjaxSupport component as facet for it's parent.
 * @author shura (latest modification by $Author: alexsmirnov $)
 * @version $Revision: 1.5 $ $Date: 2006/07/29 11:49:07 $
 *
 */
public class AjaxSupportHandler extends TagHandler {
    /**
     * A UIComponent for capturing a child UIComponent, representative of the
     * desired Facet
     * 
     * @author Jacob Hookom
     * 
     */
    private final static class UIFacet extends UIComponentBase {
        public String getFamily() {
            return null;
        }
    }

	/**
	 * Real tag handler for create component.
	 */
	private TagHandler _ajaxSupportHandler;
	
	private TagAttribute _event;
	/**
	 * @param config
	 */
	public AjaxSupportHandler(ComponentConfig config) {
		super(config);
		_event = getRequiredAttribute("event");
		_ajaxSupportHandler = new AjaxComponentHandler(config);
	}

	/* (non-Javadoc)
	 * @see com.sun.facelets.FaceletHandler#apply(com.sun.facelets.FaceletContext, javax.faces.component.UIComponent)
	 */
	public void apply(FaceletContext ctx, UIComponent parent)
			throws IOException, FacesException, FaceletException, ELException {
        UIComponent c;
        // our id
//        String id = ctx.generateUniqueId(this.tagId);
        UIFacet facet = new UIFacet();
        // Find facet for support component
        String facetName = AjaxSupportTag.AJAX_SUPPORT_FACET+_event.getValue();
		c = parent.getFacet(facetName);
        if (null != c) {
			parent.getFacets().remove(facetName);
			facet.getChildren().add(c);
		}
        this._ajaxSupportHandler.apply(ctx, facet);
        c = (UIComponent) facet.getChildren().get(0);
        parent.getFacets().put(facetName, c);
        // Fix for possible incompabilites in different frameworks.
//        c.setParentProperties(parent);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy