org.apache.myfaces.custom.aliasbean.AliasBean

A Tag aliasBean permite criar um nome temporarário para um Bean existente. Ele se torna visível somente à tags filhas do AliasBean.

É como se fosse uma simulação de um novo escopo interno para o JSP, com ele você consegue fazer com quem um pequeno trecho do seu código se comporte com algumas funcionalidades que você teria costumeiramente apenas em uma página nova. Em alguns casos tu conseguirás substituir trechos que podem ser colocados em subViews. Já falamos aqui de alguns pontos importantes em como as subviews são tratadas pelo framework e da alocação limitada que existe automaticamente dependendo da forma como o viewstate esta configurado para as páginas. Neste caso você tanbém poderá utilizar o AliasBean como forma de delegar funções específicas à ela e contidas no seu ALIAS ou temporário Bean.

Veja um exemplo retirado da especificação do MyFaces Tomahawk for JSF 1.1:


<t:aliasBean alias="#{holder}" value="#{aliasTest1}"" >

    <f:subview id="simulatedIncludedSubform1">

        <h:outputLabel for="name" value="Name:"/>

        <h:inputText id="name" value="#{holder.name}"/>

    </f:subview>  

</t:aliasBean>



Comentários originais desta Tag que citamos aqui:

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.


FONTE ORIGINAL: http://myfaces.apache.org/tomahawk-project/tomahawk/tagdoc/t_aliasBean.html

Nenhum comentário: