org.zkoss.jsf.zul.impl
Class AbstractComponent

java.lang.Object
  extended by javax.faces.component.UIComponent
      extended by javax.faces.component.UIComponentBase
          extended by org.zkoss.jsf.zul.impl.AbstractComponent
All Implemented Interfaces:
javax.faces.component.StateHolder
Direct Known Subclasses:
BaseAttribute, BaseComponentDefinition, BaseCustomAttributes, BaseInit, BaseZScript, LeafComponent, RootComponent

public class AbstractComponent
extends javax.faces.component.UIComponentBase

The skeletal class for implementing the generic ZULJSF Component. This component handle _if, _unless attributes of ZUL Component. This component also handle bodyContent which is set by AbstractTag.doAfterBody()

Author:
Dennis.Chen

Field Summary
 
Fields inherited from class javax.faces.component.UIComponent
bindings
 
Constructor Summary
AbstractComponent()
           
 
Method Summary
protected  javax.faces.component.UIComponent findAncestorWithClass(javax.faces.component.UIComponent component, java.lang.Class clazz)
          A convenient method for finding ancestor of special class.
protected  java.lang.String getBodyContent()
          get the body content of this ZULJSF Component.
protected  org.zkoss.jsf.zul.impl.ComponentInfo getComponentInfo()
          Get ComponentInfo for current Component Tree.
 javax.faces.context.FacesContext getFacesContext()
          get current FacesContext for this component, this method is protected in super class, I public it for convenient usage.
 java.lang.String getFamily()
          get Component Family of ZULJSF Component.
 boolean getIf()
          Returns the if condition.
 boolean getUnless()
          Returns the unless condition.
 boolean isEffective()
          Returns whether this component is effective.
protected  boolean isSuppressed()
          Return true if rendering should be suppressed because of any of the follow reasons.
protected  void loadZULTree(org.zkoss.zk.ui.Page page, java.io.StringWriter writer)
          Call by RootComponent or BranchComponent to load tree structure of zk zul components.
protected static java.util.Map restoreAttachedMapState(javax.faces.context.FacesContext context, java.lang.Object keys, java.lang.Object values)
          a convenient to restore the state of a Map.
 void restoreState(javax.faces.context.FacesContext context, java.lang.Object state)
          Override Method, restore the state of this component.
protected static java.lang.Object[] saveAttachedMapState(javax.faces.context.FacesContext context, java.util.Map mapObject)
          a convenient to save the state of a Map.
 java.lang.Object saveState(javax.faces.context.FacesContext context)
          Override Method, save the state of this component.
 void setBodyContent(java.lang.String content)
          Set BodyContnet, this method is called by AbstractTag to setup JSP Body Content, developer rarely call this method.
 void setIf(boolean ifcond)
          Sets the if condition.
 void setSuppressed(boolean suppressed)
          set suppressed by AbstractTag only, developer should not call this method.
 void setUnless(boolean unless)
          Sets the unless condition.
 
Methods inherited from class javax.faces.component.UIComponentBase
addFacesListener, broadcast, decode, encodeBegin, encodeChildren, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientId, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getParent, getRenderer, getRendererType, getRendersChildren, getValueBinding, invokeOnComponent, isRendered, isTransient, processDecodes, processRestoreState, processSaveState, processUpdates, processValidators, queueEvent, removeFacesListener, restoreAttachedState, saveAttachedState, setId, setParent, setRendered, setRendererType, setTransient, setValueBinding
 
Methods inherited from class javax.faces.component.UIComponent
encodeAll, getContainerClientId, getValueExpression, setValueExpression
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractComponent

public AbstractComponent()
Method Detail

isEffective

public boolean isEffective()
Returns whether this component is effective. If false, this component does nothing (as if not specified at all).


getIf

public boolean getIf()
Returns the if condition. If the if condition is false, this component is ignored. If the unless condition (getUnless()) is true, this component is ignored, too. Components deriving from this class shall invoke isEffective() to know the result.

Default: true.


setIf

public void setIf(boolean ifcond)
Sets the if condition.


getUnless

public boolean getUnless()
Returns the unless condition. If the unless condition is true, this component is ignored. If the if condition (getIf()) is true, this component is ignored, too. Components deriving from this class shall invoke isEffective() to know the result.

Default: false.


setUnless

public void setUnless(boolean unless)
Sets the unless condition.


getFamily

public java.lang.String getFamily()
get Component Family of ZULJSF Component.

Specified by:
getFamily in class javax.faces.component.UIComponent

findAncestorWithClass

protected javax.faces.component.UIComponent findAncestorWithClass(javax.faces.component.UIComponent component,
                                                                  java.lang.Class clazz)
A convenient method for finding ancestor of special class. this method is use to build ZULJSF component tree under JSF component tree.

Parameters:
component - a component, usually a AbstractComponent instance
clazz - a class, usually a AbstractComponent class
Returns:
a ancestor Component

loadZULTree

protected void loadZULTree(org.zkoss.zk.ui.Page page,
                           java.io.StringWriter writer)
                    throws java.io.IOException
Call by RootComponent or BranchComponent to load tree structure of zk zul components. This method is invoked from a RootComponent's encodeEnd() or a BranchComponent's loadZK(). It will go through all ZULJSF Component Tree to initial ZUL Component of corresponding ZULJSFComponent.
Note: Do nothing in default implementation.

Throws:
java.io.IOException

setBodyContent

public void setBodyContent(java.lang.String content)
Set BodyContnet, this method is called by AbstractTag to setup JSP Body Content, developer rarely call this method.

Parameters:
content - content of this component

getBodyContent

protected java.lang.String getBodyContent()
get the body content of this ZULJSF Component.

Returns:
the body content of JSP

getFacesContext

public javax.faces.context.FacesContext getFacesContext()
get current FacesContext for this component, this method is protected in super class, I public it for convenient usage.

Overrides:
getFacesContext in class javax.faces.component.UIComponentBase

getComponentInfo

protected org.zkoss.jsf.zul.impl.ComponentInfo getComponentInfo()
Get ComponentInfo for current Component Tree.
In LeafComponent, it always return RootComponent's getComponentInfo(), if RootComponent doesn't exist return null;
In RootComponet , it check a existed instance and return it, if not, a new instance will be created and return.
Note : return null in default implementation.

Returns:
a ComponentInfo of current Component Tree

saveState

public java.lang.Object saveState(javax.faces.context.FacesContext context)
Override Method, save the state of this component.

Specified by:
saveState in interface javax.faces.component.StateHolder
Overrides:
saveState in class javax.faces.component.UIComponentBase

restoreState

public void restoreState(javax.faces.context.FacesContext context,
                         java.lang.Object state)
Override Method, restore the state of this component.

Specified by:
restoreState in interface javax.faces.component.StateHolder
Overrides:
restoreState in class javax.faces.component.UIComponentBase

saveAttachedMapState

protected static java.lang.Object[] saveAttachedMapState(javax.faces.context.FacesContext context,
                                                         java.util.Map mapObject)
a convenient to save the state of a Map.

Parameters:
context - FacesContext
mapObject - a Map to save
Returns:
two handled Object, Object[0] handle the state of keys of Map, Object[1] handle the state of values of Map.

restoreAttachedMapState

protected static java.util.Map restoreAttachedMapState(javax.faces.context.FacesContext context,
                                                       java.lang.Object keys,
                                                       java.lang.Object values)
a convenient to restore the state of a Map.

Parameters:
context - FacesContext
keys - a Object which is create by saveAttachedMapState(javax.faces.context.FacesContext, java.util.Map)[0]
values - a Object which is create by saveAttachedMapState(javax.faces.context.FacesContext, java.util.Map)[1]
Returns:
restored Map instance

isSuppressed

protected boolean isSuppressed()

Return true if rendering should be suppressed because of any of the follow reasons.


setSuppressed

public void setSuppressed(boolean suppressed)
set suppressed by AbstractTag only, developer should not call this method.

Parameters:
suppressed -


Copyright © 2005-2007 Potix Corporation. All Rights Reserved.