/**
 * 
 */
package org.ajax4jsf.component;

import javax.faces.component.NamingContainer;
import javax.faces.component.UIComponentBase;
import javax.faces.context.FacesContext;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * @author asmirnov
 *
 */
public class UIPortlet extends UIComponentBase implements NamingContainer {

	
    private static final Log _log = LogFactory.getLog(UIPortlet.class);
    /**
     * <p>The standard component type for this component.</p>
     */
    public static final String COMPONENT_TYPE = "org.ajax4jsf.Portlet";
    
    
    /**
     * <p>The standard component family for this component.</p>
     */
    public static final String COMPONENT_FAMILY = "org.ajax4jsf.Portlet";

    /* (non-Javadoc)
     * @see javax.faces.component.UIComponent#getFamily()
     */
    public String getFamily() {
	// TODO Auto-generated method stub
	return COMPONENT_FAMILY;
    }
    
    private String portletId = null;
    
    @Override
    public void setId(String id) {
    	portletId = null;
    	super.setId(id);
    }
    
    // ----------------------------------------------------- UIComponent Methods
    public String getClientId(FacesContext context) {
        if (portletId == null) {
                portletId = context.getExternalContext().encodeNamespace(super.getClientId(context));
        }
        return portletId;
    }

}
