Done! Thanks! I have put your class in the sources.
If you, or anyone else for that matters, want to fix /add more
handlers to the projects feel free to tell me and I can add you as
members right away!
Thanks,
Bruno
On 23/10/2007, Mario Ivankovits <[EMAIL PROTECTED]> 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
>
>