You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2010/01/29 00:13:18 UTC

svn commit: r904296 [2/3] - in /myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces: component/html/ component/html/ext/ custom/aliasbean/ custom/datascroller/ custom/document/ custom/inputHtml/ custom/schedule/ custom/tabbedpane/ custom/tre...

Added: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/datascroller/AbstractHtmlDataScroller.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/datascroller/AbstractHtmlDataScroller.java?rev=904296&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/datascroller/AbstractHtmlDataScroller.java (added)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/datascroller/AbstractHtmlDataScroller.java Thu Jan 28 23:13:17 2010
@@ -0,0 +1,954 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.apache.myfaces.custom.datascroller;
+
+import javax.el.ValueExpression;
+import javax.faces.FacesException;
+import javax.faces.component.ActionSource;
+import javax.faces.component.PartialStateHolder;
+import javax.faces.component.StateHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIData;
+import javax.faces.component.UIPanel;
+import javax.faces.component.behavior.ClientBehaviorHolder;
+import javax.faces.context.FacesContext;
+import javax.faces.el.EvaluationException;
+import javax.faces.el.MethodBinding;
+import javax.faces.el.ValueBinding;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.ActionListener;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.PhaseId;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFComponent;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFFacet;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFProperty;
+import org.apache.myfaces.component.AttachedDeltaWrapper;
+import org.apache.myfaces.component.DisplayValueOnlyAware;
+import org.apache.myfaces.component.ForceIdAware;
+import org.apache.myfaces.component.StyleAware;
+import org.apache.myfaces.component.UniversalProperties;
+import org.apache.myfaces.component.UserRoleAware;
+import org.apache.myfaces.component.UserRoleUtils;
+import org.apache.myfaces.component.html.util.HtmlComponentUtils;
+import org.apache.myfaces.shared_tomahawk.component.DisplayValueOnlyCapable;
+
+/**
+ * Scroller for UIData components eg. dataTable
+ *
+ * Must be nested inside footer facet of dataTable OR for
+ * attribute must be given so that corresponding uiData can be found.
+ *
+ * Unless otherwise specified, all attributes accept static values or EL expressions.
+ *
+ * A component which works together with a UIData component to allow a
+ * user to view a large list of data one "page" at a time, and navigate
+ * between pages.
+ *
+ * @since 1.1.7
+ * @author Thomas Spiegl (latest modification by $Author: hazems $)
+ * @version $Revision: 752423 $ $Date: 2009-03-11 06:10:49 -0500 (mié, 11 mar 2009) $
+ */
+@JSFComponent(
+    name = "t:dataScroller",
+    clazz = "org.apache.myfaces.custom.datascroller.HtmlDataScroller",
+    tagClass = "org.apache.myfaces.custom.datascroller.HtmlDataScrollerTag")
+public abstract class AbstractHtmlDataScroller extends UIPanel
+    implements ActionSource, ClientBehaviorHolder, UserRoleAware, DisplayValueOnlyCapable,
+    DisplayValueOnlyAware, ForceIdAware, UniversalProperties, StyleAware
+{
+
+    public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlDataScroller";
+    public static final String COMPONENT_FAMILY = "javax.faces.Panel";
+    private static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.DataScroller";
+    private static final boolean DEFAULT_IMMEDIATE = false;
+
+    private static final Log log = LogFactory.getLog(AbstractHtmlDataScroller.class);
+
+    private static final String FIRST_FACET_NAME = "first";
+    private static final String LAST_FACET_NAME = "last";
+    private static final String NEXT_FACET_NAME = "next";
+    private static final String PREVIOUS_FACET_NAME = "previous";
+    private static final String FAST_FORWARD_FACET_NAME = "fastforward";
+    private static final String FAST_REWIND_FACET_NAME = "fastrewind";
+
+    public static final String FACET_FIRST = "first".intern();
+    public static final String FACET_PREVIOUS = "previous".intern();
+    public static final String FACET_NEXT = "next".intern();
+    public static final String FACET_LAST = "last".intern();
+    public static final String FACET_FAST_FORWARD = "fastf".intern();
+    public static final String FACET_FAST_REWIND = "fastr".intern();
+
+    private static final String TABLE_LAYOUT = "table";
+    private static final String LIST_LAYOUT = "list";
+    private static final String SINGLE_LIST_LAYOUT = "singleList";
+    private static final String SINGLE_TABLE_LAYOUT = "singleTable";
+
+    // just for caching the associated uidata
+    private transient UIData _UIData;
+
+    private transient Boolean _listLayout;
+
+    private transient Boolean _singleElementLayout;
+
+    private MethodBinding _actionListener;
+
+    public String getClientId(FacesContext context)
+    {
+        String clientId = HtmlComponentUtils.getClientId(this, getRenderer(context), context);
+        if (clientId == null)
+        {
+            clientId = super.getClientId(context);
+        }
+
+        return clientId;
+    }
+
+    public boolean isRendered()
+    {
+        if (!UserRoleUtils.isVisibleOnUserRole(this)) return false;
+        return super.isRendered();
+    }
+
+    public boolean isSetDisplayValueOnly(){
+        return getDisplayValueOnly() != null ? true : false;
+    }
+
+    public boolean isDisplayValueOnly(){
+        return getDisplayValueOnly() != null ? getDisplayValueOnly().booleanValue() : false;
+    }
+
+    public void setDisplayValueOnly(boolean displayValueOnly){
+        this.setDisplayValueOnly((Boolean) Boolean.valueOf(displayValueOnly));
+    }
+
+    /**
+     *  The layout this scroller should render with. Default is 'table',
+     *  'list' is implemented as well. Additionally you can use
+     *  'singleList' - then the data-scroller will render a list, but
+     *  not the paginator - same with the value 'singleTable'.
+     *
+     */
+    @JSFProperty(
+       defaultValue = "table")
+    public abstract String getLayout();
+
+    /**
+     * standard html colspan attribute for table cell
+     *
+     */
+    @JSFProperty(defaultValue = "Integer.MIN_VALUE")
+    public abstract int getColspan();
+
+    /**
+     * HTML: Script to be invoked when the element is clicked.
+     *
+     */
+    @JSFProperty
+    public abstract String getOnclick();
+
+    /**
+     * HTML: Script to be invoked when the element is double-clicked.
+     *
+     */
+    @JSFProperty
+    public abstract String getOndblclick();
+
+    public boolean isListLayout()
+    {
+        if(_listLayout == null)
+        {
+            String layout=getLayout();
+            if(layout == null || layout.equals(TABLE_LAYOUT) || layout.equals(SINGLE_TABLE_LAYOUT))
+                _listLayout = Boolean.FALSE;
+            else if(layout.equals(LIST_LAYOUT) || layout.equals(SINGLE_LIST_LAYOUT))
+            {
+                _listLayout = Boolean.TRUE;
+            }
+            else
+            {
+                log.error("Invalid layout-parameter : "+layout +" provided. Defaulting to table-layout.");
+                _listLayout = Boolean.FALSE;
+            }
+        }
+
+        return _listLayout.booleanValue();
+    }
+
+    public boolean isSingleElementLayout()
+    {
+        if(_singleElementLayout == null)
+        {
+            String layout=getLayout();
+            if(layout == null || layout.equals(SINGLE_LIST_LAYOUT) || layout.equals(SINGLE_TABLE_LAYOUT))
+                _singleElementLayout = Boolean.TRUE;
+            else
+                _singleElementLayout = Boolean.FALSE;
+        }
+
+        return _singleElementLayout.booleanValue();
+    }
+
+    /**
+     * Catch any attempts to queue events for this component, and ensure
+     * the event's phase is set appropriately. Events are expected to be
+     * queued by this component's renderer.
+     * <p>
+     * When this component is marked "immediate", any ActionEvent will
+     * be marked to fire in the "apply request values" phase. When this
+     * component is not immediate the event will fire during the
+     * "invoke application" phase instead.
+     */
+    public void queueEvent(FacesEvent event)
+    {
+        if (event != null && event instanceof ActionEvent)
+        {
+            if (isImmediate())
+            {
+                event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
+            }
+            else
+            {
+                event.setPhaseId(PhaseId.INVOKE_APPLICATION);
+            }
+        }
+        super.queueEvent(event);
+    }
+
+    /**
+     * Invoke any action listeners attached to this class.
+     * <p>
+     * After listener invocation, the associated UIData's properties get
+     * updated:
+     * <ul>
+     * <li>if the user selected an absolute page# then setFirst is called with
+     * uiData.getRows() * pageNumber.
+     * <li>if the user selected the "first page" option then setFirst(0) is called.
+     * <li>if the user selected the "previous page" option then setFirst is decremented
+     * by uiData.getRows().
+     * <li>if the user selected the "fast rewind" option then setFirst is decremented
+     * by uiData.getRows() * fastStep.
+     * <li>next, fast-forward and last options have the obvious effect.
+     * </ul>
+     */
+    public void broadcast(FacesEvent event) throws AbortProcessingException
+    {
+        super.broadcast(event);
+
+        if (event instanceof ScrollerActionEvent)
+        {
+            ScrollerActionEvent scrollerEvent = (ScrollerActionEvent) event;
+
+            broadcastToActionListener(scrollerEvent);
+
+            // huh? getUIData never returns null.
+            UIData uiData = getUIData();
+            if (uiData == null)
+            {
+                return;
+            }
+
+            int pageindex = scrollerEvent.getPageIndex();
+            if (pageindex == -1)
+            {
+                String facet = scrollerEvent.getScrollerfacet();
+                if (FACET_FIRST.equals(facet))
+                {
+                    setFirst(uiData, 0);
+                }
+                else if (FACET_PREVIOUS.equals(facet))
+                {
+                    int previous = uiData.getFirst() - uiData.getRows();
+                    if (previous >= 0)
+                        setFirst(uiData, previous);
+                }
+                else if (FACET_NEXT.equals(facet))
+                {
+                    int next = uiData.getFirst() + uiData.getRows();
+                    if (next < uiData.getRowCount())
+                        setFirst(uiData, next);
+                }
+                else if (FACET_FAST_FORWARD.equals(facet))
+                {
+                    int fastStep = getFastStep();
+                    if (fastStep <= 0)
+                        fastStep = 1;
+                    int next = uiData.getFirst() + uiData.getRows() * fastStep;
+                    int rowcount = uiData.getRowCount();
+                    if (next >= rowcount)
+                        next = (rowcount - 1) - ((rowcount - 1) % uiData.getRows());
+                    setFirst(uiData, next);
+                }
+                else if (FACET_FAST_REWIND.equals(facet))
+                {
+                    int fastStep = getFastStep();
+                    if (fastStep <= 0)
+                        fastStep = 1;
+                    int previous = uiData.getFirst() - uiData.getRows() * fastStep;
+                    if (previous < 0)
+                        previous = 0;
+                    setFirst(uiData, previous);
+                }
+                else if (FACET_LAST.equals(facet))
+                {
+                    int rowcount = uiData.getRowCount();
+                    int rows = uiData.getRows();
+                    int delta = (rows != 0) ? (rowcount % rows) : 0;
+                    int first = delta > 0 && delta < rows ? rowcount - delta : rowcount - rows;
+                    if (first >= 0)
+                    {
+                        setFirst(uiData, first);
+                    }
+                    else
+                    {
+                        setFirst(uiData, 0);
+                    }
+                }
+            }
+            else
+            {
+                int pageCount = getPageCount();
+                if (pageindex > pageCount)
+                {
+                    pageindex = pageCount;
+                }
+                if (pageindex <= 0)
+                {
+                    pageindex = 1;
+                }
+                setFirst(uiData, uiData.getRows() * (pageindex - 1));
+            }
+        }
+    }
+
+    protected void setFirst(UIData uiData, int value) {
+        //there might be special cases where the first-property of the data-table
+        //is bound to a backing bean. If this happens, the user probably wants
+        //the data-scroller to update this backing-bean value - if not, you can always
+        //override this method in a subclass.
+        if(uiData.getValueBinding("first")!=null)
+        {
+            ValueBinding vb = uiData.getValueBinding("first");
+            vb.setValue(getFacesContext(),new Integer(value));
+        }
+        else
+        {
+            uiData.setFirst(value);
+        }
+    }
+
+    /**
+     * @param event
+     */
+    protected void broadcastToActionListener(ScrollerActionEvent event)
+    {
+        FacesContext context = getFacesContext();
+
+        MethodBinding actionListenerBinding = getActionListener();
+        if (actionListenerBinding != null)
+        {
+            try
+            {
+                actionListenerBinding.invoke(context, new Object[] {event});
+            }
+            catch (EvaluationException e)
+            {
+                Throwable cause = e.getCause();
+                if (cause != null && cause instanceof AbortProcessingException)
+                {
+                    throw (AbortProcessingException)cause;
+                }
+                throw e;
+            }
+        }
+
+        ActionListener defaultActionListener
+                = context.getApplication().getActionListener();
+        if (defaultActionListener != null)
+        {
+            defaultActionListener.processAction((ActionEvent)event);
+        }
+    }
+
+    /**
+     * @return int
+     */
+    public UIData getUIData()
+    {
+        if (_UIData == null)
+        {
+            _UIData = findUIData();
+        }
+        return _UIData;
+    }
+
+    /**
+     * @return the page index of the uidata
+     */
+    public int getPageIndex()
+    {
+        UIData uiData = getUIData();
+        int rows = uiData.getRows();
+        if (0 == rows)
+        {
+            throw new FacesException("You need to set a value to the 'rows' attribute of component '" + uiData.getClientId(getFacesContext()) + "'" );
+        }
+
+        int pageIndex;
+        if (rows > 0)
+        {
+            pageIndex = uiData.getFirst() / rows + 1;
+        }
+        else
+        {
+            log.warn("DataTable " + uiData.getClientId(FacesContext.getCurrentInstance())
+                            + " has invalid rows attribute.");
+            pageIndex = 0;
+        }
+        if (uiData.getFirst() % rows > 0)
+        {
+            pageIndex++;
+        }
+        return pageIndex;
+    }
+
+    /**
+     * @return the page count of the uidata
+     */
+    public int getPageCount()
+    {
+        UIData uiData = getUIData();
+        int rows = uiData.getRows();
+        int pageCount;
+        if (rows > 0)
+        {
+            pageCount = rows <= 0 ? 1 : uiData.getRowCount() / rows;
+            if (uiData.getRowCount() % rows > 0)
+            {
+                pageCount++;
+            }
+        }
+        else
+        {
+            rows = 1;
+            pageCount = 1;
+        }
+        return pageCount;
+    }
+
+    /**
+     * @return int
+     */
+    public int getRowCount()
+    {
+        return getUIData().getRowCount();
+    }
+
+    /**
+     * @return int
+     */
+    public int getRows()
+    {
+        return getUIData().getRows();
+    }
+
+    /**
+     * @return int
+     */
+    public int getFirstRow()
+    {
+        return getUIData().getFirst();
+    }
+
+    /**
+     * Find the UIData component associated with this scroller.
+     * <p>
+     * If the "for" attribute is not null then that value is used to find the
+     * specified component by id. Both "relative" and "absolute" ids are allowed;
+     * see method UIComponent.findComponent for details.
+     * <p>
+     * If the "for" attribute is not defined, then this component is expected to
+     * be a child of a UIData component.
+     *
+     * @throws IllegalArgumentException if an associated UIData component
+     * cannot be found.
+     */
+    protected UIData findUIData()
+    {
+        String forStr = getFor();
+        UIComponent forComp;
+        if (forStr == null)
+        {
+            // DataScroller may be a child of uiData
+            forComp = getParent();
+        }
+        else
+        {
+            forComp = findComponent(forStr);
+        }
+        if (forComp == null)
+        {
+            throw new IllegalArgumentException(
+                    "could not find UIData referenced by attribute dataScroller@for = '"
+                    + forStr + "'");
+        }
+        else if (!(forComp instanceof UIData))
+        {
+            throw new IllegalArgumentException(
+                "uiComponent referenced by attribute dataScroller@for = '"
+                + forStr + "' must be of type " + UIData.class.getName()
+                + ", not type " + forComp.getClass().getName());
+        }
+        return (UIData) forComp;
+    }
+
+    public void setFirst(UIComponent first)
+    {
+        getFacets().put(FIRST_FACET_NAME, first);
+    }
+
+    /**
+     */
+    @JSFFacet
+    public UIComponent getFirst()
+    {
+        return (UIComponent) getFacets().get(FIRST_FACET_NAME);
+    }
+
+    public void setLast(UIComponent last)
+    {
+        getFacets().put(LAST_FACET_NAME, last);
+    }
+
+    /**
+     */
+    @JSFFacet
+    public UIComponent getLast()
+    {
+        return (UIComponent) getFacets().get(LAST_FACET_NAME);
+    }
+
+    public void setNext(UIComponent next)
+    {
+        getFacets().put(NEXT_FACET_NAME, next);
+    }
+
+    /**
+     */
+    @JSFFacet
+    public UIComponent getNext()
+    {
+        return (UIComponent) getFacets().get(NEXT_FACET_NAME);
+    }
+
+    public void setFastForward(UIComponent previous)
+    {
+        getFacets().put(FAST_FORWARD_FACET_NAME, previous);
+    }
+
+    /**
+     */
+    @JSFFacet
+    public UIComponent getFastForward()
+    {
+        return (UIComponent) getFacets().get(FAST_FORWARD_FACET_NAME);
+    }
+
+    public void setFastRewind(UIComponent previous)
+    {
+        getFacets().put(FAST_REWIND_FACET_NAME, previous);
+    }
+
+    /**
+     */
+    @JSFFacet
+    public UIComponent getFastRewind()
+    {
+        return (UIComponent) getFacets().get(FAST_REWIND_FACET_NAME);
+    }
+
+    public void setPrevious(UIComponent previous)
+    {
+        getFacets().put(PREVIOUS_FACET_NAME, previous);
+    }
+
+    /**
+     * 
+     */
+    @JSFFacet
+    public UIComponent getPrevious()
+    {
+        return (UIComponent) getFacets().get(PREVIOUS_FACET_NAME);
+    }
+
+    public boolean getRendersChildren()
+    {
+        return true;
+    }
+
+    /**
+     * @see javax.faces.component.ActionSource#getAction()
+     */
+    public MethodBinding getAction()
+    {
+        // not used
+        return null;
+    }
+
+    /**
+     * @see javax.faces.component.ActionSource#setAction(javax.faces.el.MethodBinding)
+     */
+    public void setAction(MethodBinding action)
+    {
+        throw new UnsupportedOperationException(
+                        "defining an action is not supported. use an actionlistener");
+    }
+
+    /**
+     * @see javax.faces.component.ActionSource#setActionListener(javax.faces.el.MethodBinding)
+     */
+    public void setActionListener(MethodBinding actionListener)
+    {
+        _actionListener = actionListener;
+        if (initialStateMarked())
+        {
+            getStateHelper().put(PropertyKeys.actionListenerSet,Boolean.TRUE);
+        }
+    }
+    
+    private boolean _isSetActionListener()
+    {
+        Boolean value = (Boolean) getStateHelper().get(PropertyKeys.actionListenerSet);
+        return value == null ? false : value;
+    }
+
+    /**
+     * MethodBinding pointing at method acception an ActionEvent with return type void.
+     *
+     * @see javax.faces.component.ActionSource#getActionListener()
+     */
+    @JSFProperty(
+       returnSignature="void",
+       methodSignature="javax.faces.event.ActionEvent")
+    public MethodBinding getActionListener()
+    {
+        if (_actionListener != null)
+        {
+            return _actionListener;
+        }
+        ValueExpression expression = getValueExpression("actionListener");
+        if (expression != null)
+        {
+            return (MethodBinding) expression.getValue(getFacesContext()
+                    .getELContext());
+        }
+        return null;
+    }
+
+    /**
+     * @see javax.faces.component.ActionSource#addActionListener(javax.faces.event.ActionListener)
+     */
+    public void addActionListener(ActionListener listener)
+    {
+        addFacesListener(listener);
+    }
+
+    /**
+     * @see javax.faces.component.ActionSource#getActionListeners()
+     */
+    public ActionListener[] getActionListeners()
+    {
+        return (ActionListener[]) getFacesListeners(ActionListener.class);
+    }
+
+    /**
+     * @see javax.faces.component.ActionSource#removeActionListener(javax.faces.event.ActionListener)
+     */
+    public void removeActionListener(ActionListener listener)
+    {
+        removeFacesListener(listener);
+    }
+
+    public Object saveState(FacesContext facesContext)
+    {
+        if (initialStateMarked())
+        {
+            boolean nullDelta = true;
+            Object parentSaved = super.saveState(facesContext);
+            Object actionListenerSaved = null;
+            if (!_isSetActionListener() &&
+                _actionListener != null && _actionListener instanceof PartialStateHolder)
+            {
+                //Delta
+                StateHolder holder = (StateHolder) _actionListener;
+                if (!holder.isTransient())
+                {
+                    Object attachedState = holder.saveState(facesContext);
+                    if (attachedState != null)
+                    {
+                        nullDelta = false;
+                    }
+                    actionListenerSaved = new AttachedDeltaWrapper(_actionListener.getClass(),
+                        attachedState);
+                }
+            }
+            else  if (_isSetActionListener() || _actionListener != null)
+            {
+                //Full
+                actionListenerSaved = saveAttachedState(facesContext,_actionListener);
+                nullDelta = false;
+            }        
+            if (parentSaved == null && nullDelta)
+            {
+                //No values
+                return null;
+            }
+            
+            Object[] values = new Object[2];
+            values[0] = parentSaved;
+            values[1] = actionListenerSaved;
+            return values;
+        }
+        else
+        {
+            Object[] values = new Object[2];
+            values[0] = super.saveState(facesContext);
+            values[1] = saveAttachedState(facesContext,_actionListener);
+            return values;
+        }
+    }
+
+    public void restoreState(FacesContext facesContext, Object state)
+    {
+        if (state == null)
+        {
+            return;
+        }
+        
+        Object[] values = (Object[])state;
+        super.restoreState(facesContext,values[0]);
+        if (values[1] instanceof AttachedDeltaWrapper)
+        {
+            //Delta
+            ((StateHolder)_actionListener).restoreState(facesContext, ((AttachedDeltaWrapper) values[1]).getWrappedStateObject());
+        }
+        else
+        {
+            //Full
+            _actionListener = (javax.faces.el.MethodBinding) restoreAttachedState(facesContext,values[1]);
+        }         
+    }
+
+    /**
+     * The JSF id of a UIData component that this scroller will affect.
+     *
+     * If this attribute is not present then the datascroller must be
+     * a child of a UIData component.
+     *
+     */
+    @JSFProperty
+    public abstract String getFor();
+
+    /**
+     * step (pages) used for fastforward and fastrewind
+     *
+     */
+    @JSFProperty(defaultValue="Integer.MIN_VALUE")
+    public abstract int getFastStep();
+
+    /**
+     * A parameter name, under which the actual page index is set
+     * in request scope similar to the var parameter.
+     *
+     */
+    @JSFProperty
+    public abstract String getPageIndexVar();
+
+    /**
+     * A parameter name, under which the actual page count is set
+     * in request scope similar to the var parameter.
+     *
+     */
+    @JSFProperty
+    public abstract String getPageCountVar();
+
+    /**
+     * A parameter name, under which the actual rows count is set
+     * in request scope similar to the var parameter.
+     *
+     * @JSFProperty
+     */
+    public abstract String getRowsCountVar();
+
+    /**
+     * A parameter name, under which the actual displayed rows count
+     * is set in request scope similar to the var parameter.
+     *
+     */
+    @JSFProperty
+    public abstract String getDisplayedRowsCountVar();
+
+    /**
+     * A parameter name, under which the actual first displayed row
+     * index is set in request scope similar to the var parameter.
+     *
+     */
+    @JSFProperty
+    public abstract String getFirstRowIndexVar();
+
+    /**
+     * A parameter name, under which the actual last displayed row
+     * index is set in request scope similar to the var parameter.
+     *
+     */
+    @JSFProperty
+    public abstract String getLastRowIndexVar();
+
+    /**
+     * If set true, then the paginator gets rendered
+     *
+     */
+    @JSFProperty(defaultValue = "false")
+    public abstract boolean isPaginator();
+
+    /**
+     * The maximum amount of pages to be displayed in the paginator.
+     *
+     */
+    @JSFProperty(defaultValue="Integer.MIN_VALUE")
+    public abstract int getPaginatorMaxPages();
+
+    /**
+     * styleclass for pagingator
+     *
+     */
+    @JSFProperty
+    public abstract String getPaginatorTableClass();
+
+    /**
+     * style for pagingator
+     *
+     */
+    @JSFProperty
+    public abstract String getPaginatorTableStyle();
+
+    /**
+     * styleClass for paginator's column
+     *
+     */
+    @JSFProperty
+    public abstract String getPaginatorColumnClass();
+
+    /**
+     * style for paginator's column
+     *
+     */
+    @JSFProperty
+    public abstract String getPaginatorColumnStyle();
+
+    /**
+     * styleClass for paginator's column with pageIndex = currentPageIndex
+     *
+     */
+    @JSFProperty
+    public abstract String getPaginatorActiveColumnClass();
+
+    /**
+     * 'true' - render a link for the paginator's column with
+     * pageIndex = currentPageIndex. Default-value is 'true'.
+     *
+     */
+    @JSFProperty(defaultValue="true")
+    public abstract boolean isPaginatorRenderLinkForActive();
+
+    /**
+     * style-class for data-scroller first-element
+     *
+     */
+    @JSFProperty
+    public abstract String getFirstStyleClass();
+
+    /**
+     * style-class for data-scroller last-element
+     *
+     */
+    @JSFProperty
+    public abstract String getLastStyleClass();
+
+    /**
+     * style-class for data-scroller previous-element
+     *
+     */
+    @JSFProperty
+    public abstract String getPreviousStyleClass();
+
+    /**
+     * style-class for dataScroller next-element
+     *
+     */
+    @JSFProperty
+    public abstract String getNextStyleClass();
+
+    /**
+     * style-class for data-scroller fast-forward-element
+     *
+     */
+    @JSFProperty
+    public abstract String getFastfStyleClass();
+
+    /**
+     * style-class for data-scroller fast-rewind-element
+     *
+     */
+    @JSFProperty
+    public abstract String getFastrStyleClass();
+
+    /**
+     * style for paginator's column with pageIndex = currentPageIndex
+     *
+     */
+    @JSFProperty
+    public abstract String getPaginatorActiveColumnStyle();
+
+    /**
+     * If set to false, the facets aren't renderd if all the
+     * lines are contained on a single page. Default is true.
+     *
+     */
+    @JSFProperty(defaultValue="true")
+    public abstract boolean isRenderFacetsIfSinglePage();
+
+    /**
+     * True means that the default ActionListener should be
+     * executed immediately (i.e. during Apply Request
+     * Values phase of the request processing lifecycle),
+     * rather than waiting until the Invoke Application phase.
+     *
+     */
+    @JSFProperty(defaultValue="false")
+    public abstract boolean isImmediate();
+
+    enum PropertyKeys
+    {
+        actionListenerSet
+    }
+}

Added: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/document/AbstractDocument.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/document/AbstractDocument.java?rev=904296&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/document/AbstractDocument.java (added)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/document/AbstractDocument.java Thu Jan 28 23:13:17 2010
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.apache.myfaces.custom.document;
+
+import javax.faces.component.UIComponentBase;
+
+import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFComponent;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFProperty;
+
+/**
+ * Base class to handle the document family
+ * 
+ * @JSFComponent
+ *   tagClass = "org.apache.myfaces.custom.document.AbstractDocumentTag"
+ *   configExcluded = "true"
+ *   
+ * @author Mario Ivankovits (latest modification by $Author: skitching $)
+ * @version $Revision: 673833 $ $Date: 2008-07-03 16:58:05 -0500 (jue, 03 jul 2008) $
+ */
+@JSFComponent(
+   tagClass = "org.apache.myfaces.custom.document.AbstractDocumentTag",
+   configExcluded = true)
+public class AbstractDocument extends UIComponentBase
+{
+    public static final String COMPONENT_FAMILY = "javax.faces.Data";
+
+    public AbstractDocument(String renderType)
+    {
+        setRendererType(renderType);
+    }
+
+    public String getFamily()
+    {
+        return COMPONENT_FAMILY;
+    }
+
+    public void setState(String state)
+    {
+        getStateHelper().put(PropertyKeys.state, state );
+    }
+
+    /**
+     * state="start|end". Used to demarkate the document boundaries
+     * 
+     */
+    @JSFProperty(literalOnly = true)
+    public String getState()
+    {
+        return (String)getStateHelper().get(PropertyKeys.state);
+    }
+
+    public boolean hasState()
+    {
+        return isStartState() || isEndState();
+    }
+
+    public boolean isStartState()
+    {
+        return "start".equals(getState());
+    }
+
+    public boolean isEndState()
+    {
+        return "end".equals(getState());
+    }
+    
+    protected enum PropertyKeys
+    {
+        state
+    }
+}
\ No newline at end of file

Added: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/inputHtml/InputHtml.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/inputHtml/InputHtml.java?rev=904296&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/inputHtml/InputHtml.java (added)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/inputHtml/InputHtml.java Thu Jan 28 23:13:17 2010
@@ -0,0 +1,432 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.apache.myfaces.custom.inputHtml;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.component.html.ext.HtmlInputText;
+import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils;
+import org.apache.myfaces.shared_tomahawk.util._ComponentUtils;
+
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+
+/**
+ * HTML Editor using the kupu library.
+ * http://kupu.oscom.org/
+ *
+ * An inline HTML based word processor based on the Kupu library. 
+ * 
+ * See http://kupu.oscom.org 
+ * 
+ * Right now, the support is limited to one editor per page 
+ * (but you can use tabs to have multiple editors, but only 
+ * one rendered at a time). 
+ * 
+ * Unless otherwise specified, all attributes accept static values or EL expressions.
+ *
+ * @JSFComponent
+ *   name = "t:inputHtml"
+ *   tagClass = "org.apache.myfaces.custom.inputHtml.InputHtmlTag"
+ *
+ * @author Sylvain Vieujot (latest modification by $Author: skitching $)
+ * @version $Revision: 673833 $ $Date: 2008-07-03 16:58:05 -0500 (jue, 03 jul 2008) $
+ */
+public class InputHtml extends HtmlInputText {
+    public static final String COMPONENT_TYPE = "org.apache.myfaces.InputHtml";
+
+    public static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.InputHtml";
+
+    private static final Log log = LogFactory.getLog(HtmlInputText.class);
+
+    private String _fallback;
+    private String _type;
+
+    private Boolean _allowEditSource;
+    private Boolean _allowExternalLinks;
+    private Boolean _addKupuLogo;
+
+    private Boolean _showAllToolBoxes;
+    private Boolean _showPropertiesToolBox;
+    private Boolean _showLinksToolBox;
+    private Boolean _showImagesToolBox;
+    private Boolean _showTablesToolBox;
+    private Boolean _showCleanupExpressionsToolBox;
+    private Boolean _showDebugToolBox;
+
+    public InputHtml() {
+        setRendererType(DEFAULT_RENDERER_TYPE);
+    }
+
+    public Object saveState(FacesContext context) {
+        Object values[] = new Object[4];
+        values[0] = super.saveState(context);
+
+        String[] types = new String[2];
+        types[0] = _fallback;
+        types[1] = _type;
+
+        values[1] = types;
+
+        Boolean toolBarButtons[] = new Boolean[3];
+        toolBarButtons[0] = _allowEditSource;
+        toolBarButtons[1] = _allowExternalLinks;
+        toolBarButtons[2] = _addKupuLogo;
+
+        values[2] = toolBarButtons;
+
+        Boolean toolBoxes[] = new Boolean[7];
+        toolBoxes[0] = _showAllToolBoxes;
+        toolBoxes[1] = _showPropertiesToolBox;
+        toolBoxes[2] = _showLinksToolBox;
+        toolBoxes[3] = _showImagesToolBox;
+        toolBoxes[4] = _showTablesToolBox;
+        toolBoxes[5] = _showCleanupExpressionsToolBox;
+        toolBoxes[6] = _showDebugToolBox;
+
+        values[3] = toolBoxes;
+
+        return values;
+    }
+
+    public void restoreState(FacesContext context, Object state) {
+        Object values[] = (Object[]) state;
+        super.restoreState(context, values[0]);
+
+        String[] types = (String[]) values[1];
+        _fallback = types[0];
+        _type = types[1];
+
+        Boolean[] toolBarButtons = (Boolean[]) values[2];
+        _allowEditSource = toolBarButtons[0];
+        _allowExternalLinks = toolBarButtons[1];
+        _addKupuLogo = toolBarButtons[2];
+
+        Boolean[] toolBoxes = (Boolean[]) values[3];
+        _showAllToolBoxes = toolBoxes[0];
+        _showPropertiesToolBox = toolBoxes[1];
+        _showLinksToolBox = toolBoxes[2];
+        _showImagesToolBox = toolBoxes[3];
+        _showTablesToolBox = toolBoxes[4];
+        _showCleanupExpressionsToolBox = toolBoxes[5];
+        _showDebugToolBox = toolBoxes[6];
+    }
+
+    /**
+     * Use a text area instead of the javascript HTML editor. 
+     * 
+     * Default is false. Use with caution.
+     * 
+     * @JSFProperty
+     */
+    public String getFallback(){
+        if (_fallback != null)
+            return _fallback;
+        ValueBinding vb = getValueBinding("fallback");
+        return vb != null ? vb.getValue(getFacesContext()).toString() : "false";
+    }
+    public void setFallback(String _fallback){
+        this._fallback = _fallback;
+    }
+
+    /**
+     * The type of the value. It can be either fragment for an HTML 
+     * fragment (default) or document for a full HTML document, with 
+     * head, title, body, ... tags.
+     * 
+     * @JSFProperty
+     */
+    public String getType(){
+        if (_type != null)
+            return _type;
+        ValueBinding vb = getValueBinding("type");
+        return vb != null ? _ComponentUtils.getStringValue(getFacesContext(), vb) : "fragment";
+    }
+    public void setType(String _type){
+        this._type = _type;
+    }
+    public boolean isTypeDocument(){
+        return getType().equals("document");
+    }
+
+    /**
+     * Allows the user to edit the HTML source code. Default is true.
+     * 
+     * @JSFProperty
+     */
+    public boolean isAllowEditSource(){
+           if (_allowEditSource != null)
+               return _allowEditSource.booleanValue();
+           ValueBinding vb = getValueBinding("allowEditSource");
+           return vb != null ? ((Boolean)vb.getValue(getFacesContext())).booleanValue() : true;
+    }
+    public void setAllowEditSource(boolean allowEditSource){
+        this._allowEditSource = Boolean.valueOf(allowEditSource);
+    }
+
+    /**
+     * Allows the user to insert external links. Default is true.
+     * 
+     * @JSFProperty
+     */
+    public boolean isAllowExternalLinks(){
+        if (_allowExternalLinks != null)
+            return _allowExternalLinks.booleanValue();
+        ValueBinding vb = getValueBinding("allowExternalLinks");
+        return vb != null ? ((Boolean)vb.getValue(getFacesContext())).booleanValue() : true;
+    }
+    public void setAllowExternalLinks(boolean allowExternalLinks){
+        this._allowExternalLinks = Boolean.valueOf(allowExternalLinks);
+    }
+
+    /**
+     * Show the Kupu Logo in the buttons bar. Default is true.
+     * 
+     * @JSFProperty
+     */
+    public boolean isAddKupuLogo(){
+           if (_addKupuLogo != null)
+               return _addKupuLogo.booleanValue();
+           ValueBinding vb = getValueBinding("addKupuLogo");
+           return vb != null ? ((Boolean)vb.getValue(getFacesContext())).booleanValue() : true;
+    }
+    public void setAddKupuLogo(boolean addKupuLogo){
+        this._addKupuLogo = Boolean.valueOf(addKupuLogo);
+    }
+
+    /**
+     * Shortcut to avoid setting all the showXXToolBox to true. Default is false.
+     * 
+     * @JSFProperty
+     */
+    public boolean isShowAllToolBoxes(){
+           if (_showAllToolBoxes != null)
+               return _showAllToolBoxes.booleanValue();
+        ValueBinding vb = getValueBinding("showAllToolBoxes");
+        return vb != null ? ((Boolean)vb.getValue(getFacesContext())).booleanValue() : false;
+    }
+    public void setShowAllToolBoxes(boolean showAllToolBoxes){
+        this._showAllToolBoxes = Boolean.valueOf(showAllToolBoxes);
+    }
+
+    /**
+     * Show the Properties tool box next to the text. Default is false.
+     * 
+     * @JSFProperty
+     */
+    public boolean isShowPropertiesToolBox(){
+        if( isShowAllToolBoxes() )
+            return true;
+
+           if (_showPropertiesToolBox != null)
+               return _showPropertiesToolBox.booleanValue();
+        ValueBinding vb = getValueBinding("showPropertiesToolBox");
+        return vb != null ? ((Boolean)vb.getValue(getFacesContext())).booleanValue() : false;
+    }
+
+    public void setShowPropertiesToolBox(boolean showPropertiesToolBox){
+        this._showPropertiesToolBox = Boolean.valueOf(showPropertiesToolBox);
+    }
+
+    /**
+     * Show the Links tool box next to the text. Default is false.
+     * 
+     * @JSFProperty
+     */
+    public boolean isShowLinksToolBox(){
+        if( isShowAllToolBoxes() )
+            return true;
+
+           if (_showLinksToolBox != null)
+               return _showLinksToolBox.booleanValue();
+        ValueBinding vb = getValueBinding("showLinksToolBox");
+        return vb != null ? ((Boolean)vb.getValue(getFacesContext())).booleanValue() : false;
+    }
+    
+    public void setShowLinksToolBox(boolean showLinksToolBox){
+        this._showLinksToolBox = Boolean.valueOf(showLinksToolBox);
+    }
+
+    /**
+     * Show the Images tool box next to the text. Default is false.
+     * 
+     * @JSFProperty
+     */
+    public boolean isShowImagesToolBox(){
+        if( isShowAllToolBoxes() )
+            return true;
+
+           if (_showImagesToolBox != null)
+               return _showImagesToolBox.booleanValue();
+        ValueBinding vb = getValueBinding("showImagesToolBox");
+        return vb != null ? ((Boolean)vb.getValue(getFacesContext())).booleanValue() : false;
+    }
+    public void setShowImagesToolBox(boolean showImagesToolBox){
+        this._showImagesToolBox = Boolean.valueOf(showImagesToolBox);
+    }
+
+    /**
+     * Show the Tables tool box next to the text. Default is false.
+     * 
+     * @JSFProperty
+     */
+    public boolean isShowTablesToolBox(){
+        if( isShowAllToolBoxes() )
+            return true;
+
+           if (_showTablesToolBox != null)
+               return _showTablesToolBox.booleanValue();
+        ValueBinding vb = getValueBinding("showTablesToolBox");
+        return vb != null ? ((Boolean)vb.getValue(getFacesContext())).booleanValue() : false;
+    }
+    public void setShowTablesToolBox(boolean showTablesToolBox){
+        this._showTablesToolBox = Boolean.valueOf(showTablesToolBox);
+    }
+
+    /**
+     * Show the Cleanup Expressions tool box next to the text. Default is false.
+     * 
+     * @JSFProperty
+     */
+    public boolean isShowCleanupExpressionsToolBox(){
+        if( isShowAllToolBoxes() )
+            return true;
+
+           if (_showCleanupExpressionsToolBox != null)
+               return _showCleanupExpressionsToolBox.booleanValue();
+        ValueBinding vb = getValueBinding("showCleanupExpressionsToolBox");
+        return vb != null ? ((Boolean)vb.getValue(getFacesContext())).booleanValue() : false;
+    }
+    public void setShowCleanupExpressionsToolBox(boolean showCleanupExpressionsToolBox){
+        this._showCleanupExpressionsToolBox = Boolean.valueOf(showCleanupExpressionsToolBox);
+    }
+
+    /**
+     * Show the Debug tool box next to the text. Default is false.
+     * 
+     * @JSFProperty
+     */
+    public boolean isShowDebugToolBox(){
+        if( isShowAllToolBoxes() )
+            return true;
+
+           if (_showDebugToolBox != null)
+               return _showDebugToolBox.booleanValue();
+        ValueBinding vb = getValueBinding("showDebugToolBox");
+        return vb != null ? ((Boolean)vb.getValue(getFacesContext())).booleanValue() : false;
+    }
+    public void setShowDebugToolBox(boolean showTablesToolBox){
+        this._showDebugToolBox = Boolean.valueOf(showTablesToolBox);
+    }
+
+    public boolean isShowAnyToolBox(){
+           return isShowAllToolBoxes()
+               || isShowPropertiesToolBox()
+               || isShowLinksToolBox()
+               || isShowImagesToolBox()
+               || isShowTablesToolBox()
+               || isShowCleanupExpressionsToolBox()
+               || isShowDebugToolBox();
+    }
+
+    public String getValueAsHtmlDocument(FacesContext context){
+        String val = RendererUtils.getStringValue(context, this);
+        if( isHtmlDocument( val ) )
+            return val;
+
+        return "<html><body>"+(val==null ? "" : val)+"</body></html>";
+    }
+
+    private static boolean isHtmlDocument(String text){
+        if( text == null )
+            return false;
+
+        if( text.indexOf("<body>")!=-1 || text.indexOf("<body ")!=-1
+            || text.indexOf("<BODY>")!=-1 || text.indexOf("<BODY ")!=-1 )
+            return true;
+
+        return false;
+    }
+
+    public String getValueFromDocument(String text){
+        if( text == null )
+            return "";
+
+        if( isTypeDocument() )
+            return text.trim();
+
+        if( !isHtmlDocument(text) )
+            return text.trim();
+
+        // Extract the fragment from the document.
+        String fragment = getHtmlBody( text );
+        if( fragment.endsWith("<br />") )
+            return fragment.substring(0, fragment.length()-6);
+        return fragment;
+    }
+    
+    String getHtmlBody(String html){
+        html = html.trim();
+        if( html.length() == 0 )
+            return "";
+
+        String lcText = html.toLowerCase();
+        int textLength = lcText.length();
+        int bodyStartIndex = -1;
+        while(bodyStartIndex < textLength){
+            bodyStartIndex++;
+            bodyStartIndex = lcText.indexOf("<body", bodyStartIndex);
+            if( bodyStartIndex == -1 )
+                break; // not found.
+
+            bodyStartIndex += 5;
+            char c = lcText.charAt(bodyStartIndex);
+            if( c=='>' )
+                break;
+
+            if( c!=' ' && c!='\t' )
+                continue;
+
+            bodyStartIndex = lcText.indexOf('>', bodyStartIndex);
+            break;
+        }
+        bodyStartIndex++;
+
+        int bodyEndIndex = lcText.lastIndexOf("</body>")-1;
+        
+        if( bodyStartIndex<0 || bodyEndIndex<0
+           || bodyStartIndex > bodyEndIndex
+           || bodyStartIndex>=textLength || bodyEndIndex>=textLength ){
+
+            if( lcText.indexOf("<body/>")!=-1 || lcText.indexOf("<body />")!=-1 )
+                return "";
+            
+            int htmlStartIndex = lcText.indexOf("<html>");
+            int htmlEndIndex = lcText.indexOf("</html>");
+            if( htmlStartIndex != -1 && htmlEndIndex > htmlStartIndex )
+                return html.substring(htmlStartIndex+6, htmlEndIndex);
+            
+            if( isTypeDocument() )
+                log.warn("Couldn't extract HTML body from :\n"+html);
+            return html.trim();
+        }
+
+        return html.substring(bodyStartIndex, bodyEndIndex+1).trim();
+    }
+}

Added: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/schedule/UISchedule.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/schedule/UISchedule.java?rev=904296&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/schedule/UISchedule.java (added)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/schedule/UISchedule.java Thu Jan 28 23:13:17 2010
@@ -0,0 +1,611 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.apache.myfaces.custom.schedule;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.Iterator;
+
+import javax.el.MethodExpression;
+import javax.el.ValueExpression;
+import javax.faces.component.ActionSource2;
+import javax.faces.component.PartialStateHolder;
+import javax.faces.component.StateHolder;
+import javax.faces.context.FacesContext;
+import javax.faces.el.MethodBinding;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.ActionListener;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.PhaseId;
+
+import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFComponent;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFProperty;
+import org.apache.myfaces.component.AttachedDeltaWrapper;
+import org.apache.myfaces.component.MethodBindingToMethodExpression;
+import org.apache.myfaces.component.MethodExpressionToMethodBinding;
+import org.apache.myfaces.custom.schedule.model.ScheduleDay;
+import org.apache.myfaces.custom.schedule.model.ScheduleEntry;
+
+/**
+ * This class contains all 'interactive' stuff for the Schedule component, meaning
+ * actions and actionListeners.
+ * 
+ * @author Jurgen Lust
+ * @version $Revision: 736908 $
+ */
+@JSFComponent
+public class UISchedule extends org.apache.myfaces.custom.schedule.UIScheduleBase implements
+        Serializable, ActionSource2
+{
+    public static final String COMPONENT_TYPE = "org.apache.myfaces.UISchedule";
+    
+    private class ScheduleActionListener implements ActionListener
+    {
+        //~ Methods ------------------------------------------------------------
+
+        /**
+         * @see javax.faces.event.ActionListener#processAction(javax.faces.event.ActionEvent)
+         */
+        public void processAction(ActionEvent event)
+                throws AbortProcessingException
+        {
+            UISchedule schedule = (UISchedule) event.getComponent();
+            ScheduleEntry entry = schedule.getSubmittedEntry();
+            schedule.getModel().setSelectedEntry(entry);
+            schedule.setSubmittedEntry(null);
+        }
+    }
+    
+    private static final long serialVersionUID = -8333458172939036755L;
+    //private MethodBinding _action;
+    private MethodBinding _actionListener;
+    private ScheduleActionListener _scheduleListener;
+    private ScheduleEntry _submittedEntry;
+    //private Date _lastClickedDateAndTime = null;
+    
+
+
+
+    public UISchedule()
+    {
+        super();
+        _scheduleListener = new ScheduleActionListener();
+    }
+
+    public void addActionListener(ActionListener listener)
+    {
+        addFacesListener(listener);
+    }
+
+    
+    /**
+     * @see javax.faces.component.UIComponent#broadcast(javax.faces.event.FacesEvent)
+     */
+    public void broadcast(FacesEvent event) throws AbortProcessingException
+    {
+        FacesContext context = getFacesContext();
+        //invoke the mouselistener first
+        if (event instanceof ScheduleMouseEvent)
+        {
+            ScheduleMouseEvent mouseEvent = (ScheduleMouseEvent) event;
+            MethodBinding mouseListener = getMouseListener();
+
+            if (mouseListener != null)
+            {
+                mouseListener.invoke(context,
+                        new Object[] { mouseEvent });
+            }
+        }
+        
+        //then invoke private ScheduleActionListener for set
+        //the selected entry (if exists), so other
+        //listeners can retrieve it from getSelectedEntry.
+        if (event.isAppropriateListener(_scheduleListener))
+        {
+            event.processListener(_scheduleListener);
+        }
+
+        //then invoke any other listeners
+        super.broadcast(event);
+
+        if (event instanceof ActionEvent)
+        {
+            //Call registered actionListener if applies
+            MethodBinding actionListener = getActionListener();
+    
+            if (actionListener != null)
+            {
+                actionListener.invoke(context, new Object[] { event });
+            }
+            
+            //Since UISchedule is an ActionSource component,
+            //we should call to the application actionListener
+            //when an ActionEvent happens.
+            ActionListener defaultActionListener = context.getApplication()
+                .getActionListener();
+            if (defaultActionListener != null)
+            {
+                defaultActionListener.processAction((ActionEvent) event);
+            }
+        }
+    }
+
+    /**
+     * Find the entry with the given id
+     *
+     * @param id the id
+     *
+     * @return the entry
+     */
+    protected ScheduleEntry findEntry(String id)
+    {
+        if (id == null)
+        {
+            return null;
+        }
+
+        for (Iterator dayIterator = getModel().iterator(); dayIterator
+                .hasNext();)
+        {
+            ScheduleDay day = (ScheduleDay) dayIterator.next();
+
+            for (Iterator iter = day.iterator(); iter.hasNext();)
+            {
+                ScheduleEntry entry = (ScheduleEntry) iter.next();
+
+                if (id.equals(entry.getId()))
+                {
+                    return entry;
+                }
+            }
+        }
+
+        return null;
+    }
+    
+    /**
+     * @deprecated Use setActionExpression instead.
+     */
+    public void setAction(MethodBinding action)
+    {
+        if(action != null)
+        {
+            setActionExpression(new MethodBindingToMethodExpression(action));
+        } 
+        else
+        {
+            setActionExpression(null);
+        }
+    }
+
+    /**
+     * @deprecated Use getActionExpression() instead.
+     */
+    public MethodBinding getAction()
+    {
+        MethodExpression actionExpression = getActionExpression();
+        if (actionExpression instanceof MethodBindingToMethodExpression) {
+            return ((MethodBindingToMethodExpression)actionExpression).getMethodBinding();
+        }
+        if(actionExpression != null)
+        {
+            return new MethodExpressionToMethodBinding(actionExpression);
+        }
+        return null;
+    }
+    
+    // Property: actionExpression
+    private MethodExpression _actionExpression;
+
+    /**
+     * Gets Specifies the action to take when this command is invoked.
+     *         If the value is an expression, it is expected to be a method
+     *         binding EL expression that identifies an action method. An action method
+     *         accepts no parameters and has a String return value, called the action
+     *         outcome, that identifies the next view displayed. The phase that this
+     *         event is fired in can be controlled via the immediate attribute.
+     * 
+     *         If the value is a string literal, it is treated as a navigation outcome
+     *         for the current view.  This is functionally equivalent to a reference to
+     *         an action method that returns the string literal.
+     *
+     * @return  the new actionExpression value
+     */
+    @JSFProperty(
+        returnSignature="java.lang.String",
+       jspName="action")
+    public MethodExpression getActionExpression()
+    {
+      if (_actionExpression != null)
+      {
+        return _actionExpression;
+      }
+      ValueExpression expression = getValueExpression("actionExpression");
+      if (expression != null)
+      {
+        return (MethodExpression)expression.getValue(getFacesContext().getELContext());
+      }
+      return null;
+    }
+
+    /**
+     * Sets Specifies the action to take when this command is invoked.
+     *         If the value is an expression, it is expected to be a method
+     *         binding EL expression that identifies an action method. An action method
+     *         accepts no parameters and has a String return value, called the action
+     *         outcome, that identifies the next view displayed. The phase that this
+     *         event is fired in can be controlled via the immediate attribute.
+     * 
+     *         If the value is a string literal, it is treated as a navigation outcome
+     *         for the current view.  This is functionally equivalent to a reference to
+     *         an action method that returns the string literal.
+     * 
+     * @param actionExpression  the new actionExpression value
+     */
+    public void setActionExpression(MethodExpression actionExpression)
+    {
+      this._actionExpression = actionExpression;
+      if (initialStateMarked())
+      {
+          getStateHelper().put(PropertyKeys.actionExpressionSet,Boolean.TRUE);
+      }
+    }
+    
+    private boolean _isSetActionExpression()
+    {
+        Boolean value = (Boolean) getStateHelper().get(PropertyKeys.actionExpressionSet);
+        return value == null ? false : value;
+    }
+    
+    // Property: mouseListenerExpression
+    private MethodExpression _mouseListenerExpression;
+
+    /**
+     *   
+     * @return
+     */
+    @JSFProperty(
+        returnSignature="void",
+        methodSignature="org.apache.myfaces.custom.schedule.ScheduleMouseEvent",
+        stateHolder=true,
+        jspName="mouseListener")
+    public MethodExpression getMouseListenerExpression()
+    {
+      if (_mouseListenerExpression != null)
+      {
+        return _mouseListenerExpression;
+      }
+      ValueExpression expression = getValueExpression("mouseListenerExpression");
+      if (expression != null)
+      {
+        return (MethodExpression)expression.getValue(getFacesContext().getELContext());
+      }
+      return null;
+    }
+
+    public void setMouseListenerExpression(MethodExpression mouseListenerExpression)
+    {
+      this._mouseListenerExpression = mouseListenerExpression;
+      if (initialStateMarked())
+      {
+          getStateHelper().put(PropertyKeys.mouseListenerExpressionSet,Boolean.TRUE);
+      }
+    }    
+    
+    /*
+    public MethodBinding getAction()
+    {
+        return _action;
+    }*/
+
+    /**
+     * 
+     */
+    @JSFProperty(
+        returnSignature="void",
+        methodSignature="javax.faces.event.ActionEvent")
+    public MethodBinding getActionListener()
+    {
+        return _actionListener;
+    }
+
+    public ActionListener[] getActionListeners()
+    {
+        return (ActionListener[]) getFacesListeners(ActionListener.class);
+    }
+
+    /**
+     * The last date and time of day that was clicked. This is set when
+     * submitOnClick is true, and the schedule is clicked by the user.
+     * 
+     * @return the last clicked date and time
+     */
+    @JSFProperty(tagExcluded = true)        
+    public Date getLastClickedDateAndTime()
+    {
+        return (Date) getStateHelper().get(PropertyKeys.lastClickedDateAndTime);
+    }
+    
+    /**
+     * @deprecated Use setMouseListenerExpression instead.
+     */
+    public void setMouseListener(MethodBinding mouseListener)
+    {
+        if(mouseListener != null)
+        {
+            setMouseListenerExpression(new MethodBindingToMethodExpression(mouseListener));
+        } 
+        else
+        {
+            setMouseListenerExpression(null);
+        }
+    }
+
+    /**
+     *   
+     * @return the method binding to the mouse listener method
+     */
+    public MethodBinding getMouseListener()
+    {
+        MethodExpression mouseListenerExpression = getMouseListenerExpression();
+        if (mouseListenerExpression instanceof MethodBindingToMethodExpression) {
+            return ((MethodBindingToMethodExpression)mouseListenerExpression).getMethodBinding();
+        }
+        if(mouseListenerExpression != null)
+        {
+            return new MethodExpressionToMethodBinding(mouseListenerExpression);
+        }
+        return null;
+    }
+
+    /**
+     * @return the submittedEntry
+     */
+    public ScheduleEntry getSubmittedEntry()
+    {
+        return _submittedEntry;
+    }
+
+    /**
+     * @see javax.faces.component.UIComponent#queueEvent(javax.faces.event.FacesEvent)
+     */
+    public void queueEvent(FacesEvent event)
+    {
+        if (event instanceof ActionEvent || event instanceof ScheduleMouseEvent)
+        {
+            if (isImmediate())
+            {
+                event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
+            }
+            else
+            {
+                event.setPhaseId(PhaseId.INVOKE_APPLICATION);
+            }
+        }
+
+        super.queueEvent(event);
+    }
+
+    public void removeActionListener(ActionListener listener)
+    {
+        removeFacesListener(listener);
+    }
+
+    /**
+     * This method is invoked at the beginning of the restore view phase,
+     * resetting all mouse event variables that were left from the previous
+     * request
+     */
+    protected void resetMouseEvents()
+    {
+        getStateHelper().put(PropertyKeys.lastClickedDateAndTime, null);
+    }
+
+    /**
+     * @see org.apache.myfaces.custom.schedule.UIScheduleBase#restoreState(javax.faces.context.FacesContext, java.lang.Object)
+     */
+    public void restoreState(FacesContext facesContext, Object state)
+    {
+        if (state == null)
+        {
+            return;
+        }
+        
+        Object[] values = (Object[])state;
+        super.restoreState(facesContext,values[0]);
+        if (values[1] instanceof AttachedDeltaWrapper)
+        {
+            //Delta
+            ((StateHolder)_actionListener).restoreState(facesContext, ((AttachedDeltaWrapper) values[1]).getWrappedStateObject());
+        }
+        else
+        {
+            //Full
+            _actionListener = (javax.faces.el.MethodBinding) restoreAttachedState(facesContext,values[1]);
+        }         
+        if (values[2] instanceof AttachedDeltaWrapper)
+        {
+            //Delta
+            ((StateHolder)_actionExpression).restoreState(facesContext, ((AttachedDeltaWrapper) values[2]).getWrappedStateObject());
+        }
+        else
+        {
+            //Full
+            _actionExpression = (javax.el.MethodExpression) restoreAttachedState(facesContext,values[2]);
+        }         
+        if (values[3] instanceof AttachedDeltaWrapper)
+        {
+            //Delta
+            ((StateHolder)_mouseListenerExpression).restoreState(facesContext, ((AttachedDeltaWrapper) values[3]).getWrappedStateObject());
+        }
+        else
+        {
+            //Full
+            _mouseListenerExpression = (javax.el.MethodExpression) restoreAttachedState(facesContext,values[3]);
+        }         
+    }
+    
+    /**
+     * @see org.apache.myfaces.custom.schedule.UIScheduleBase#saveState(javax.faces.context.FacesContext)
+     */
+    public Object saveState(FacesContext facesContext)
+    {
+        if (initialStateMarked())
+        {
+            boolean nullDelta = true;
+            Object parentSaved = super.saveState(facesContext);
+            Object actionListenerSaved = null;
+            if (!_isSetActionListener() &&
+                _actionListener != null && _actionListener instanceof PartialStateHolder)
+            {
+                //Delta
+                StateHolder holder = (StateHolder) _actionListener;
+                if (!holder.isTransient())
+                {
+                    Object attachedState = holder.saveState(facesContext);
+                    if (attachedState != null)
+                    {
+                        nullDelta = false;
+                    }
+                    actionListenerSaved = new AttachedDeltaWrapper(_actionListener.getClass(),
+                        attachedState);
+                }
+            }
+            else  if (_isSetActionListener() || _actionListener != null)
+            {
+                //Full
+                actionListenerSaved = saveAttachedState(facesContext,_actionListener);
+                nullDelta = false;
+            }        
+            Object actionExpressionSaved = null;
+            if (!_isSetActionExpression() &&
+                _actionExpression != null && _actionExpression instanceof PartialStateHolder)
+            {
+                //Delta
+                StateHolder holder = (StateHolder) _actionExpression;
+                if (!holder.isTransient())
+                {
+                    Object attachedState = holder.saveState(facesContext);
+                    if (attachedState != null)
+                    {
+                        nullDelta = false;
+                    }
+                    actionExpressionSaved = new AttachedDeltaWrapper(_actionExpression.getClass(),
+                        attachedState);
+                }
+            }
+            else  if (_isSetActionExpression() || _actionExpression != null)
+            {
+                //Full
+                actionExpressionSaved = saveAttachedState(facesContext,_actionExpression);
+                nullDelta = false;
+            }        
+            Object mouseListenerExpressionSaved = null;
+            if (!_isSetActionListener() &&
+                _mouseListenerExpression != null && _mouseListenerExpression instanceof PartialStateHolder)
+            {
+                //Delta
+                StateHolder holder = (StateHolder) _mouseListenerExpression;
+                if (!holder.isTransient())
+                {
+                    Object attachedState = holder.saveState(facesContext);
+                    if (attachedState != null)
+                    {
+                        nullDelta = false;
+                    }
+                    mouseListenerExpressionSaved = new AttachedDeltaWrapper(_mouseListenerExpression.getClass(),
+                        attachedState);
+                }
+            }
+            else  if (_isSetActionListener() || _mouseListenerExpression != null)
+            {
+                //Full
+                mouseListenerExpressionSaved = saveAttachedState(facesContext,_mouseListenerExpression);
+                nullDelta = false;
+            }        
+            if (parentSaved == null && nullDelta)
+            {
+                //No values
+                return null;
+            }
+            
+            Object[] values = new Object[4];
+            values[0] = parentSaved;
+            values[1] = actionListenerSaved;
+            values[2] = actionExpressionSaved;
+            values[3] = mouseListenerExpressionSaved;
+            return values;
+        }
+        else
+        {
+            Object[] values = new Object[4];
+            values[0] = super.saveState(facesContext);
+            values[1] = saveAttachedState(facesContext, _actionListener);
+            values[2] = saveAttachedState(facesContext, _actionExpression);
+            values[3] = saveAttachedState(facesContext, _mouseListenerExpression);
+            return values;
+        }
+    }
+
+    
+
+    public void setActionListener(MethodBinding actionListener)
+    {
+        this._actionListener = actionListener;
+        if (initialStateMarked())
+        {
+            getStateHelper().put(PropertyKeys.actionListenerSet,Boolean.TRUE);
+        }
+    }
+
+    private boolean _isSetActionListener()
+    {
+        Boolean value = (Boolean) getStateHelper().get(PropertyKeys.actionListenerSet);
+        return value == null ? false : value;
+    }
+    
+    /**
+     * The last date and time of day that was clicked. This is set when
+     * submitOnClick is true, and the schedule is clicked by the user.
+     * 
+     * @return the last clicked date and time
+     */
+    protected void setLastClickedDateAndTime(Date lastClickedDateAndTime)
+    {
+        getStateHelper().put(PropertyKeys.lastClickedDateAndTime, lastClickedDateAndTime);
+    }
+
+
+    /**
+     * @param submittedEntry the submittedEntry to set
+     */
+    protected void setSubmittedEntry(ScheduleEntry submittedEntry)
+    {
+        this._submittedEntry = submittedEntry;
+    }
+    
+    protected enum PropertyKeys
+    {
+        lastClickedDateAndTime
+        , actionExpressionSet
+        , actionListenerSet
+        , mouseListenerExpressionSet
+    }
+}

Added: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tabbedpane/AbstractHtmlPanelTabbedPane.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tabbedpane/AbstractHtmlPanelTabbedPane.java?rev=904296&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tabbedpane/AbstractHtmlPanelTabbedPane.java (added)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tabbedpane/AbstractHtmlPanelTabbedPane.java Thu Jan 28 23:13:17 2010
@@ -0,0 +1,438 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.apache.myfaces.custom.tabbedpane;
+
+import java.util.Iterator;
+import java.util.List;
+
+import javax.faces.component.PartialStateHolder;
+import javax.faces.component.StateHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIForm;
+import javax.faces.component.UINamingContainer;
+import javax.faces.component.html.HtmlPanelGroup;
+import javax.faces.context.FacesContext;
+import javax.faces.el.EvaluationException;
+import javax.faces.el.MethodBinding;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.PhaseId;
+
+import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFProperty;
+import org.apache.myfaces.component.AlignProperty;
+import org.apache.myfaces.component.AttachedDeltaWrapper;
+import org.apache.myfaces.component.DataProperties;
+import org.apache.myfaces.component.EventAware;
+import org.apache.myfaces.component.PanelProperties;
+import org.apache.myfaces.component.UniversalProperties;
+import org.apache.myfaces.component.UserRoleAware;
+
+/**
+ * TODO: Document this component.
+ * 
+ * Unless otherwise specified, all attributes accept static values or EL expressions.
+ * 
+ * @JSFComponent
+ *   name = "t:panelTabbedPane"
+ *   class = "org.apache.myfaces.custom.tabbedpane.HtmlPanelTabbedPane"
+ *   tagClass = "org.apache.myfaces.custom.tabbedpane.HtmlPanelTabbedPaneTag"
+ *   tagHandler = "org.apache.myfaces.custom.tabbedpane.HtmlPanelTabbedPaneTagHandler"
+ * 
+ * @author Manfred Geiler (latest modification by $Author: lu4242 $)
+ * @version $Revision: 745263 $ $Date: 2009-02-17 16:51:58 -0500 (mar, 17 feb 2009) $
+ */
+public abstract class AbstractHtmlPanelTabbedPane
+        extends HtmlPanelGroup
+        implements UniversalProperties, EventAware, PanelProperties,
+        AlignProperty, DataProperties, UserRoleAware
+        
+{
+    //private static final Log log = LogFactory.getLog(HtmlPanelTabbedPane.class);
+
+    public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlPanelTabbedPane";
+    public static final String COMPONENT_FAMILY = "javax.faces.Panel";
+    private static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.TabbedPane";
+    private static final int DEFAULT_SELECTEDINDEX = 0;
+    private static final boolean DEFAULT_SERVER_SIDE_TAB_SWITCH = false;
+
+    private MethodBinding _tabChangeListener = null;
+    private static final int DEFAULT_BORDER = Integer.MIN_VALUE;
+
+    public void decode(FacesContext context)
+    {
+        super.decode(context);    //To change body of overridden methods use File | Settings | File Templates.
+    }
+
+    public void processDecodes(javax.faces.context.FacesContext context)
+   {
+       if (context == null) throw new NullPointerException("context");
+       decode(context);
+
+       int tabIdx = 0;
+       int selectedIndex = getSelectedIndex();
+
+       Iterator it = getFacetsAndChildren();
+
+       while (it.hasNext())
+       {
+           UIComponent childOrFacet = getUIComponent((UIComponent) it.next());
+           if (childOrFacet instanceof HtmlPanelTab) {
+               if (isClientSide() || selectedIndex == tabIdx) {
+                   childOrFacet.processDecodes(context);
+               }
+               tabIdx++;
+           } else {
+               childOrFacet.processDecodes(context);
+           }
+       }
+   }
+
+    public void processValidators(FacesContext context)
+    {
+        if (context == null) throw new NullPointerException("context");
+        if (!isRendered()) return;
+
+        int tabIdx = 0;
+        int selectedIndex = getSelectedIndex();
+
+        Iterator it = getFacetsAndChildren();
+
+        while (it.hasNext())
+        {
+            UIComponent childOrFacet = getUIComponent((UIComponent) it.next());
+            if (childOrFacet instanceof HtmlPanelTab) {
+                if (isClientSide() || selectedIndex == tabIdx) {
+                    childOrFacet.processValidators(context);
+                }
+                tabIdx++;
+            } else {
+                childOrFacet.processValidators(context);
+            }
+        }
+    }
+
+    public void processUpdates(FacesContext context)
+    {
+        if (context == null) throw new NullPointerException("context");
+        if (!isRendered()) return;
+
+        int tabIdx = 0;
+        int selectedIndex = getSelectedIndex();
+
+        Iterator it = getFacetsAndChildren();
+
+        while (it.hasNext())
+        {
+            UIComponent childOrFacet = getUIComponent((UIComponent) it.next());
+            if (childOrFacet instanceof HtmlPanelTab) {
+                if (isClientSide() || selectedIndex == tabIdx) {
+                    childOrFacet.processUpdates(context);
+                }
+                tabIdx++;
+            } else {
+                childOrFacet.processUpdates(context);
+            }
+        }
+    }
+
+    private UIComponent getUIComponent(UIComponent uiComponent)
+    {
+        /*todo: checking for UIForm is not enough - Trinidad form, etc.*/
+        if (uiComponent instanceof UINamingContainer || uiComponent instanceof UIForm)
+        {
+            List children = uiComponent.getChildren();
+            for (int i = 0, len = children.size(); i < len; i++)
+            {
+                uiComponent = getUIComponent((UIComponent)children.get(i));
+            }
+        }
+        return uiComponent;
+    }
+
+    public void addTabChangeListener(TabChangeListener listener)
+    {
+        addFacesListener(listener);
+    }
+
+    public void removeTabChangeListener(TabChangeListener listener)
+    {
+        removeFacesListener(listener);
+    }
+
+    /**
+     * TODO: This should be something like this:
+     * 
+     * JSFProperty
+     *   returnSignature = "void"
+     *   methodSignature = "org.apache.myfaces.custom.tabbedpane.TabChangeEvent"
+     * 
+     * And be added on tld. But you can do the same with TabChangeListenerTag. 
+     * 
+     * @return
+     */
+    public MethodBinding getTabChangeListener()
+    {
+        return _tabChangeListener;
+    }
+    
+    private boolean _isSetTabChangeListener()
+    {
+        Boolean value = (Boolean) getStateHelper().get(PropertyKeys.tabChangeListenerSet);
+        return value == null ? false : value;
+    }
+    
+    public void setTabChangeListener(MethodBinding tabChangeListener)
+    {
+        _tabChangeListener = tabChangeListener;
+    }
+    
+    public Object saveState(FacesContext facesContext)
+    {
+        if (initialStateMarked())
+        {
+            boolean nullDelta = true;
+            Object parentSaved = super.saveState(facesContext);
+            Object tabChangeListenerSaved = null;
+            if (!_isSetTabChangeListener() &&
+                _tabChangeListener != null && _tabChangeListener instanceof PartialStateHolder)
+            {
+                //Delta
+                StateHolder holder = (StateHolder) _tabChangeListener;
+                if (!holder.isTransient())
+                {
+                    Object attachedState = holder.saveState(facesContext);
+                    if (attachedState != null)
+                    {
+                        nullDelta = false;
+                    }
+                    tabChangeListenerSaved = new AttachedDeltaWrapper(_tabChangeListener.getClass(),
+                        attachedState);
+                }
+            }
+            else  if (_isSetTabChangeListener() || _tabChangeListener != null)
+            {
+                //Full
+                tabChangeListenerSaved = saveAttachedState(facesContext,_tabChangeListener);
+                nullDelta = false;
+            }        
+            if (parentSaved == null && nullDelta)
+            {
+                //No values
+                return null;
+            }
+            
+            Object[] values = new Object[2];
+            values[0] = parentSaved;
+            values[1] = tabChangeListenerSaved;
+            return values;
+        }
+        else
+        {
+            Object[] values = new Object[2];
+            values[0] = super.saveState(facesContext);
+            values[1] = saveAttachedState(facesContext,_tabChangeListener);
+            return values;
+        }
+    }
+
+    public void restoreState(FacesContext facesContext, Object state)
+    {
+        if (state == null)
+        {
+            return;
+        }
+        
+        Object[] values = (Object[])state;
+        super.restoreState(facesContext,values[0]);
+        if (values[1] instanceof AttachedDeltaWrapper)
+        {
+            //Delta
+            ((StateHolder)_tabChangeListener).restoreState(facesContext, ((AttachedDeltaWrapper) values[1]).getWrappedStateObject());
+        }
+        else
+        {
+            //Full
+            _tabChangeListener = (javax.faces.el.MethodBinding) restoreAttachedState(facesContext,values[1]);
+        }
+    }    
+
+    public void broadcast(FacesEvent event) throws AbortProcessingException
+    {
+        if (event instanceof TabChangeEvent)
+        {
+            TabChangeEvent tabChangeEvent = (TabChangeEvent)event;
+            if (tabChangeEvent.getComponent() == this)
+            {
+                setSelectedIndex(tabChangeEvent.getNewTabIndex());
+                getFacesContext().renderResponse();
+            }
+        }
+        super.broadcast(event);
+
+        MethodBinding tabChangeListenerBinding = getTabChangeListener();
+        if (tabChangeListenerBinding != null)
+        {
+            try
+            {
+                tabChangeListenerBinding.invoke(getFacesContext(), new Object[]{event});
+            }
+            catch (EvaluationException e)
+            {
+                Throwable cause = e.getCause();
+                if (cause != null && cause instanceof AbortProcessingException)
+                {
+                    throw (AbortProcessingException)cause;
+                }
+                else
+                {
+                    throw e;
+                }
+            }
+        }
+    }
+    
+    /**
+     * Write out information about the toggling mode - the component might
+     * be toggled server side or client side.
+     */
+    public boolean isClientSide()
+    {
+        return !isServerSideTabSwitch(); 
+    }
+
+    /**
+     * 
+     */
+    @JSFProperty(
+       tagExcluded = true)
+    public abstract String getActiveTabVar();
+    
+    /**
+     * Boolean Variable that is set in request scope when 
+     * rendering a panelTab. True means that the currently 
+     * rendered panelTab is active.
+     * 
+     */
+    @JSFProperty
+    public abstract Boolean getActivePanelTabVar();
+
+    /**
+     * Index of tab that is selected by default.
+     * 
+     */
+    @JSFProperty(
+       defaultValue = "0")
+    public abstract int getSelectedIndex();
+    
+    public abstract void setSelectedIndex(int selectedIndex);
+
+    /**
+     * Style class of the active tab cell.
+     * 
+     */
+    @JSFProperty
+    public abstract String getActiveTabStyleClass();
+
+    /**
+     * Style class of the inactive tab cells.
+     * 
+     */
+    @JSFProperty
+    public abstract String getInactiveTabStyleClass();
+
+    /**
+     * Style class of the active tab sub cell.
+     * 
+     */
+    @JSFProperty
+    public abstract String getActiveSubStyleClass();
+
+    /**
+     * Style class of the inactive tab sub cells.
+     * 
+     */
+    @JSFProperty
+    public abstract String getInactiveSubStyleClass();
+
+    /**
+     * Style class of the active tab content cell.
+     * 
+     */
+    @JSFProperty
+    public abstract String getTabContentStyleClass();
+
+    /**
+     * Style class of the disabled tab cells.
+     * 
+     */
+    @JSFProperty
+    public abstract String getDisabledTabStyleClass();
+
+    /**
+     * Toggle client-side/server-side tab switches.
+     * 
+     */
+    @JSFProperty(
+       defaultValue = "false")
+    public abstract boolean isServerSideTabSwitch();
+    
+    public boolean getServerSideTabSwitch()
+    {
+        return isServerSideTabSwitch();
+    }
+
+    /**
+     * Define if the process validation and update model phases
+     * should be executed before change between tabs, when
+     * serverSideTabSwitch = true (if is false, the switch
+     * is done by other way so this property does not have any
+     * effect).
+     * 
+     * Note that if this property is set as false, only a tab 
+     * change is done if all input fields inside the form are valid 
+     * (including input components outside this panel). 
+     * 
+     * By default is true, so both phases are not executed.
+     * 
+     */
+    @JSFProperty(
+       defaultValue = "true")
+    public abstract boolean isImmediateTabChange();
+    
+    public void queueEvent(FacesEvent event)
+    {
+        if (event != null && event instanceof TabChangeEvent)
+        {
+            if (isImmediateTabChange())
+            {
+                event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
+            }
+            else
+            {
+                event.setPhaseId(PhaseId.INVOKE_APPLICATION);
+            }
+        }
+        super.queueEvent(event);
+    }
+    
+    enum PropertyKeys
+    {
+        tabChangeListenerSet
+    }
+}