org.apache.myfaces.custom.aliasbean
Class AliasBean

java.lang.Object
  extended by javax.faces.component.UIComponent
      extended by javax.faces.component.UIComponentBase
          extended by org.apache.myfaces.custom.aliasbean.AliasBean
All Implemented Interfaces:
EventListener, javax.faces.component.PartialStateHolder, javax.faces.component.StateHolder, javax.faces.event.ComponentSystemEventListener, javax.faces.event.FacesListener, javax.faces.event.SystemEventListenerHolder, org.apache.myfaces.shared_tomahawk.component.BindingAware

@JSFComponent(name="t:aliasBean",
              tagClass="org.apache.myfaces.custom.aliasbean.AliasBeanTag",
              tagHandler="org.apache.myfaces.custom.aliasbean.AliasBeanTagHandler")
@JSFJspProperties(properties={@JSFJspProperty(name="rendered",returnType="boolean",tagExcluded=true),@JSFJspProperty(name="binding",returnType="java.lang.String",tagExcluded=true)})
public class AliasBean
extends javax.faces.component.UIComponentBase
implements org.apache.myfaces.shared_tomahawk.component.BindingAware

The aliasBean tag allows you to create a temporary name for a real bean. The temporary name exists (is visible) only to the children of the aliasBean.

One use of this feature is to pass "parameters" from an including page to an included one. The included page can use any name it desires for beans it needs to reference, and the including page can then use aliasBean to make those names refer to the beans it wishes to "pass" as parameters.

Suppose you have a block of components you use often but with different beans. You can create a separate JSP page (or equivalent) containing these beans, where the value-bindings refer to some fictive bean name. Document these names as the required "parameters" for this JSP page. Wherever you wish to use this block you then declare an alias component mapping each of these "parameters" to whatever beans (or literal values) you really want to apply the block to, then use jsp:include (or equivalent) to include the reusable block of components.

Note, however, that AliasBean does not work for component bindings; JSF1.1 just has no mechanism available to set up the alias during the "restore view" phase while the bindings of its children are being re-established, and then remove the alias after the child bindings are done.

As a special case, if this component's direct parent is an AliasBeansScope then the alias (temporary name) is active until the end of the parent component, rather than the end of this component.

Version:
$Revision: 690079 $ $Date: 2008-08-28 21:58:51 -0500 (jue, 28 ago 2008) $
Author:
Sylvain Vieujot (latest modification by $Author: lu4242 $)

Field Summary
static String COMPONENT_FAMILY
           
static String COMPONENT_TYPE
           
 
Fields inherited from class javax.faces.component.UIComponent
BEANINFO_KEY, bindings, COMPOSITE_COMPONENT_TYPE_KEY, COMPOSITE_FACET_NAME, CURRENT_COMPONENT, CURRENT_COMPOSITE_COMPONENT, FACETS_KEY, VIEW_LOCATION_KEY
 
Constructor Summary
AliasBean()
           
 
Method Summary
 void broadcast(javax.faces.event.FacesEvent event)
           
 void encodeBegin(javax.faces.context.FacesContext context)
           
 void encodeEnd(javax.faces.context.FacesContext context)
           
 String getFamily()
           
 String getRendererType()
           
 String getValue()
          The existing value that the alias can be set to.
 void handleBindings()
          Deprecated. 
 boolean invokeOnComponent(javax.faces.context.FacesContext context, String clientId, javax.faces.component.ContextCallback callback)
           
 void processDecodes(javax.faces.context.FacesContext context)
           
 void processRestoreState(javax.faces.context.FacesContext context, Object state)
           
 Object processSaveState(javax.faces.context.FacesContext context)
           
 void processUpdates(javax.faces.context.FacesContext context)
           
 void processValidators(javax.faces.context.FacesContext context)
           
 void queueEvent(javax.faces.event.FacesEvent event)
           
 void restoreState(javax.faces.context.FacesContext context, Object state)
           
 Object saveState(javax.faces.context.FacesContext context)
           
 void setAlias(String aliasBeanExpression)
          Define the "fictive" name which will be visible to the children of this component as an alias to the "real" object specified by the value attribute of this component.
 void setValue(String valueExpression)
           
 boolean visitTree(javax.faces.component.visit.VisitContext context, javax.faces.component.visit.VisitCallback callback)
           
 
Methods inherited from class javax.faces.component.UIComponentBase
addClientBehavior, addFacesListener, clearInitialState, decode, encodeAll, encodeChildren, findComponent, getAttributes, getChildCount, getChildren, getClientBehaviors, getClientId, getDefaultEventName, getEventNames, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getParent, getRenderer, getRendersChildren, getValueBinding, initialStateMarked, isRendered, isTransient, markInitialState, removeFacesListener, restoreAttachedState, saveAttachedState, setId, setParent, setRendered, setRendererType, setTransient, setValueBinding
 
Methods inherited from class javax.faces.component.UIComponent
getClientId, getCompositeComponentParent, getContainerClientId, getCurrentComponent, getCurrentCompositeComponent, getListenersForEventClass, getNamingContainer, getResourceBundleMap, getStateHelper, getStateHelper, getValueExpression, isCompositeComponent, isInView, isVisitable, popComponentFromEL, processEvent, pushComponentToEL, setInView, setValueExpression, subscribeToEvent, unsubscribeFromEvent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMPONENT_TYPE

public static final String COMPONENT_TYPE
See Also:
Constant Field Values

COMPONENT_FAMILY

public static final String COMPONENT_FAMILY
See Also:
Constant Field Values
Constructor Detail

AliasBean

public AliasBean()
Method Detail

getFamily

public String getFamily()
Specified by:
getFamily in class javax.faces.component.UIComponent

getRendererType

public String getRendererType()
Overrides:
getRendererType in class javax.faces.component.UIComponentBase

setAlias

@JSFProperty
public void setAlias(String aliasBeanExpression)
Define the "fictive" name which will be visible to the children of this component as an alias to the "real" object specified by the value attribute of this component.

Parameters:
aliasBeanExpression -

getValue

@JSFProperty(deferredValueType="java.lang.Object")
public String getValue()
The existing value that the alias can be set to. This can be a literal string (like "toto") or a reference to an existing bean (like "#{myBean.member1}").


setValue

public void setValue(String valueExpression)

saveState

public Object saveState(javax.faces.context.FacesContext context)
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,
                         Object state)
Specified by:
restoreState in interface javax.faces.component.StateHolder
Overrides:
restoreState in class javax.faces.component.UIComponentBase

processSaveState

public Object processSaveState(javax.faces.context.FacesContext context)
Overrides:
processSaveState in class javax.faces.component.UIComponentBase

processRestoreState

public void processRestoreState(javax.faces.context.FacesContext context,
                                Object state)
Overrides:
processRestoreState in class javax.faces.component.UIComponentBase

processValidators

public void processValidators(javax.faces.context.FacesContext context)
Overrides:
processValidators in class javax.faces.component.UIComponentBase

processDecodes

public void processDecodes(javax.faces.context.FacesContext context)
Overrides:
processDecodes in class javax.faces.component.UIComponentBase

processUpdates

public void processUpdates(javax.faces.context.FacesContext context)
Overrides:
processUpdates in class javax.faces.component.UIComponentBase

encodeBegin

public void encodeBegin(javax.faces.context.FacesContext context)
                 throws IOException
Overrides:
encodeBegin in class javax.faces.component.UIComponentBase
Throws:
IOException

encodeEnd

public void encodeEnd(javax.faces.context.FacesContext context)
               throws IOException
Overrides:
encodeEnd in class javax.faces.component.UIComponentBase
Throws:
IOException

queueEvent

public void queueEvent(javax.faces.event.FacesEvent event)
Overrides:
queueEvent in class javax.faces.component.UIComponentBase

broadcast

public void broadcast(javax.faces.event.FacesEvent event)
               throws javax.faces.event.AbortProcessingException
Overrides:
broadcast in class javax.faces.component.UIComponentBase
Throws:
javax.faces.event.AbortProcessingException

handleBindings

@Deprecated
public void handleBindings()
Deprecated. 

Specified by:
handleBindings in interface org.apache.myfaces.shared_tomahawk.component.BindingAware

invokeOnComponent

public boolean invokeOnComponent(javax.faces.context.FacesContext context,
                                 String clientId,
                                 javax.faces.component.ContextCallback callback)
                          throws javax.faces.FacesException
Overrides:
invokeOnComponent in class javax.faces.component.UIComponentBase
Throws:
javax.faces.FacesException

visitTree

public boolean visitTree(javax.faces.component.visit.VisitContext context,
                         javax.faces.component.visit.VisitCallback callback)
Overrides:
visitTree in class javax.faces.component.UIComponentBase


Copyright © 2012 The Apache Software Foundation. All Rights Reserved.