myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Kienenberger" <mkien...@gmail.com>
Subject Re: facelets taglib for tomahawk and sandbox
Date Tue, 23 Oct 2007 19:58:43 GMT
Hey Mario,

The reason that there is no alias bean handler is because it's not
needed with facelets.

Instead you'd use a Facelets composition and ui:include statement.


On 10/23/07, Mario Ivankovits <mario@ops.co.at> wrote:
> Hi!
>
> Please consider adding the following handler for the AliasBean to your
> project:
> (This is my first Tag-Handler, so I am not sure if there is a more
> elegant way - at least the AliasBean works here now)
>
> import com.sun.facelets.FaceletContext;
> import com.sun.facelets.FaceletException;
> import com.sun.facelets.tag.TagAttribute;
> import com.sun.facelets.tag.TagHandler;
> import com.sun.facelets.tag.jsf.ComponentConfig;
> import org.apache.myfaces.custom.aliasbean.AliasBean;
>
> import javax.el.ELException;
> import javax.faces.FacesException;
> import javax.faces.application.Application;
> import javax.faces.component.UIComponent;
> import javax.faces.webapp.UIComponentTag;
> import java.io.IOException;
>
> public class AliasBeanHandler extends TagHandler
> {
>     private TagAttribute valueAttr;
>     private TagAttribute aliasAttr;
>
>     public AliasBeanHandler(ComponentConfig tagConfig)
>     {
>         super(tagConfig);
>
>         valueAttr = getRequiredAttribute("value");
>         aliasAttr = getRequiredAttribute("alias");
>     }
>
>
>     public void apply(FaceletContext ctx, UIComponent parent) throws
> IOException, FacesException, FaceletException, ELException
>     {
>         Application app = ctx.getFacesContext().getApplication();
>
>         AliasBean aliasBean = new AliasBean();
>
>         String value = valueAttr.getValue();
>         if (UIComponentTag.isValueReference(value))
>         {
>             aliasBean.setValueBinding("value",
> app.createValueBinding(valueAttr.getValue()));
>         }
>         else
>         {
>             aliasBean.setValue(value);
>         }
>
>         String alias = aliasAttr.getValue();
>         if (UIComponentTag.isValueReference(alias))
>         {
>             aliasBean.setValueBinding("alias",
> app.createValueBinding(aliasAttr.getValue()));
>         }
>         else
>         {
>             aliasBean.setAlias(alias);
>         }
>
>         parent.getChildren().add(aliasBean);
>     }
> }
>
> Thanks!
> Ciao,
> Mario
>
>

Mime
View raw message