Project Documentation


Tag name: <t:aliasBean>
UIComponent class: org.apache.myfaces.custom.aliasbean.AliasBean
Tag class: org.apache.myfaces.custom.aliasbean.AliasBeanTag
Component type: org.apache.myfaces.AliasBean
Component family: javax.faces.Data

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.


<t:aliasBean alias="#{holder}" value="#{aliasTest1}"" >
    <f:subview id="simulatedIncludedSubform1">
        <h:outputLabel for="name" value="Name:"/>
        <h:inputText id="name" value="#{}"/>


See examples/aliasBean.jsp for an example!


Name Type Supports EL? Description
alias String Yes 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.
id String Yes An identifier for this particular component instance within a component view.

The id must be unique within the scope of the tag's enclosing NamingContainer (eg h:form or f:subview). The id is not necessarily unique across all components in the current view

This value must be a static value, ie not change over the lifetime of a component. It cannot be defined via an EL expression; only a string is permitted.

value String Yes 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}").