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

org.ajax4jsf.taglib.ajax.AjaxCommandLinkTag 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!
/**
 * Copyright 2004 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * 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.taglib.ajax;

import javax.faces.component.UIComponent;
import javax.faces.component.html.HtmlCommandLink;

import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
import org.ajax4jsf.framework.taglib.HtmlComponentTagBase;
import org.ajax4jsf.renderers.ajax.AjaxCommandLinkRenderer;


/**
 * @author shura
 * Create HtmlCommandLink component with custom
 * Ajax renderer.
 */
public class AjaxCommandLinkTag extends HtmlComponentTagBase {

    public static final String AJAX_LINK_TYPE = "link";
    
    // HTML anchor attributes relevant for command link
    private String _accesskey;
    private String _charset;
    private String _coords;
    private String _hreflang;
    private String _rel;
    private String _rev;
    private String _shape;
    private String _tabindex;
    private String _type;
    private String _target;
    //HtmlCommandLink Attributes
    //FIXME: is mentioned in JSF API, but is no official anchor-attribute of HTML 4.0... what to do?
    private String _onblur;
    //FIXME: is mentioned in JSF API, but is no official anchor-attribute of HTML 4.0... what to do?
    private String _onfocus;

    // UICommand attributes
    private String _action;
    private String _immediate;
    private String _actionListener;

    /**
     * Id ( in form of findComponent method param ) of JSF component,
     * updated by this component ( parnt tag ) action.
     */
    private String reRender = null;
    
    /**
     * Generate script for given event ( onclick, onenter ... )
     */
    private String event = null;
    
    
    /**
     * Id of request status component.
     */
    private String status = null;
    
    /**
     * JavaScript function for call after request completed.
     */
    private String oncomplete = null ;
    
    /**
     * If "true" , on client side update only defined by targetId areas.
     */
    private String limitToList = null;
    /**
     * Type of input field. 
     */
    private String ajaxType = AJAX_LINK_TYPE;

	private String ajaxSingle = null;

    /**
	 * @param accesskey The accesskey to set.
	 */
	public void setAccesskey(String accesskey) {
		_accesskey = accesskey;
	}

	/**
	 * @param action The action to set.
	 */
	public void setAction(String action) {
		_action = action;
	}

	/**
	 * @param actionListener The actionListener to set.
	 */
	public void setActionListener(String actionListener) {
		_actionListener = actionListener;
	}

	/**
	 * @param charset The charset to set.
	 */
	public void setCharset(String charset) {
		_charset = charset;
	}

	/**
	 * @param coords The coords to set.
	 */
	public void setCoords(String coords) {
		_coords = coords;
	}

	/**
	 * @param hreflang The hreflang to set.
	 */
	public void setHreflang(String hreflang) {
		_hreflang = hreflang;
	}

	/**
	 * @param immediate The immediate to set.
	 */
	public void setImmediate(String immediate) {
		_immediate = immediate;
	}

	/**
	 * @param onblur The onblur to set.
	 */
	public void setOnblur(String onblur) {
		_onblur = onblur;
	}

	/**
	 * @param onfocus The onfocus to set.
	 */
	public void setOnfocus(String onfocus) {
		_onfocus = onfocus;
	}

	/**
	 * @param rel The rel to set.
	 */
	public void setRel(String rel) {
		_rel = rel;
	}

	/**
	 * @param rev The rev to set.
	 */
	public void setRev(String rev) {
		_rev = rev;
	}

	/**
	 * @param shape The shape to set.
	 */
	public void setShape(String shape) {
		_shape = shape;
	}

	/**
	 * @param tabindex The tabindex to set.
	 */
	public void setTabindex(String tabindex) {
		_tabindex = tabindex;
	}

	/**
	 * @param target The target to set.
	 */
	public void setTarget(String target) {
		_target = target;
	}

	/**
	 * @param type The type to set.
	 */
	public void setType(String type) {
		_type = type;
	}

	/**
     * @param ajaxType The ajaxType to set.
     */
    public void setAjaxType(String ajaxType)
    {
        this.ajaxType = ajaxType;
    }

    /**
     * @param event The event to set.
     */
    public void setEvent(String event)
    {
        this.event = event;
    }

    /**
     * @param limitToList The limitToList to set.
     */
    public void setLimitToList(String limitToList)
    {
        this.limitToList = limitToList;
    }

    /**
     * @param oncomplete The oncomplete to set.
     */
    public void setOncomplete(String oncomplete)
    {
        this.oncomplete = oncomplete;
    }

    /**
     * @param status The status to set.
     */
    public void setStatus(String status)
    {
        this.status = status;
    }

    /**
     * @param targetId The targetId to set.
     */
    public void setReRender(String targetId)
    {
        this.reRender = targetId;
    }

    /**
	 * @param ajaxSingle The ajaxSingle to set.
	 */
	public void setAjaxSingle(String ajaxSingle) {
		this.ajaxSingle = ajaxSingle;
	}

	/* (non-Javadoc)
     * @see org.ajax4jsf.components.taglib.html.HtmlCommandButtonTagBase#setProperties(javax.faces.component.UIComponent)
     */
    protected void setProperties(UIComponent component)
    {
        // TODO Auto-generated method stub
        super.setProperties(component);
        setStringProperty(component, HTML.accesskey_ATTRIBUTE, _accesskey);
        setStringProperty(component, HTML.CHARSET_ATTR, _charset);
        setStringProperty(component, HTML.COORDS_ATTR, _coords);
        setStringProperty(component, HTML.HREFLANG_ATTR, _hreflang);
        setStringProperty(component, HTML.REL_ATTR, _rel);
        setStringProperty(component, HTML.REV_ATTR, _rev);
        setStringProperty(component, HTML.SHAPE_ATTR, _shape);
        setStringProperty(component, HTML.tabindex_ATTRIBUTE, _tabindex);
        setStringProperty(component, HTML.TYPE_ATTR, _type);
        setStringProperty(component, HTML.onblur_ATTRIBUTE, _onblur);
        setStringProperty(component, HTML.onfocus_ATTRIBUTE, _onfocus);
        setStringProperty(component, HTML.target_ATTRIBUTE, _target);
        setActionProperty(component, _action);
        setActionListenerProperty(component, _actionListener);
        setBooleanProperty(component, "immediate", _immediate);
        
//        setStringProperty(component, "event", event);
        setStringProperty(component, AjaxRendererUtils.AJAX_REGIONS_ATTRIBUTE, reRender);
        setStringProperty(component, AjaxRendererUtils.STATUS_ATTR_NAME, status);
        setStringProperty(component, AjaxRendererUtils.ONCOMPLETE_ATTR_NAME, oncomplete);
        setStringProperty(component, "ajaxType", ajaxType );
        setBooleanProperty(component, AjaxRendererUtils.LIMITTOLIST_ATTR_NAME, limitToList);
        setBooleanProperty(component,"ajaxSingle",ajaxSingle );
    }

    /* (non-Javadoc)
     * @see org.ajax4jsf.components.taglib.html.HtmlCommandButtonTagBase#release()
     */
    public void release()
    {
        // TODO Auto-generated method stub
        super.release();
        // Common commandLink attributes
        _accesskey=null;
        _charset=null;
        _coords=null;
        _hreflang=null;
        _rel=null;
        _rev=null;
        _shape=null;
        _tabindex=null;
        _type=null;
        _target=null;
        _onblur=null;
        _onfocus=null;
        _action=null;
        _immediate=null;
        _actionListener=null;
        // Ajax Link attributes
        reRender=null;
        event = null;
        ajaxType = AJAX_LINK_TYPE;
        limitToList = null;
        oncomplete = null;
        status = null;
        ajaxSingle = null;
    }
/*
     * (non-Javadoc)
     * 
     * @see javax.faces.webapp.UIComponentTag#getComponentType()
     */
    public String getComponentType() {
        return HtmlCommandLink.COMPONENT_TYPE;
    }

    /*
     * (non-Javadoc)
     * 
     * @see javax.faces.webapp.UIComponentTag#getRendererType()
     */
    public String getRendererType() {
        return AjaxCommandLinkRenderer.RENDERER_TYPE;
    }

    
    

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy