You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by Apache Wiki <wi...@apache.org> on 2007/10/23 21:41:45 UTC

[Myfaces Wiki] Update of "Use Facelets with Tomahawk" by MarioIvankovits

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Myfaces Wiki" for change notification.

The following page has been changed by MarioIvankovits:
http://wiki.apache.org/myfaces/Use_Facelets_with_Tomahawk

The comment on the change is:
added alias bean tag handler

------------------------------------------------------------------------------
          <component>
              <component-type>org.apache.myfaces.AliasBean</component-type>
              <renderer-type>org.apache.myfaces.AliasBean</renderer-type>
+             <handler-class>your.package.AliasBeanHandler</handler-class>
          </component>
      </tag>
      <tag>
@@ -1035, +1036 @@

  Aleksei Valikov
  ----
  
+ Tag-Handler for AliasBean
+ 
+ {{{
+ 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);
+ 	}
+ }}}}
+ 
+ Mario Ivankovits
+ ----
+