Differences between revisions 3 and 4
Revision 3 as of 2007-02-22 17:38:22
Size: 2015
Comment:
Revision 4 as of 2009-09-20 23:01:37
Size: 2015
Editor: localhost
Comment: converted to 1.6 markup
No differences found!

tomahawk.taglib.xml

<tag>
      <tag-name>tabChangeListener</tag-name>
      <handler-class>facelets.TabChangeListenerHandler</handler-class>
</tag>

TabChangeListenerHandler.java

import java.io.IOException;

import javax.el.ELException;
import javax.faces.FacesException;
import javax.faces.component.UIComponent;

import org.apache.myfaces.custom.tabbedpane.HtmlPanelTabbedPane;
import org.apache.myfaces.custom.tabbedpane.TabChangeListener;
import org.apache.myfaces.shared_tomahawk.util.ClassUtils;

import com.sun.facelets.FaceletContext;
import com.sun.facelets.FaceletException;
import com.sun.facelets.tag.TagAttribute;
import com.sun.facelets.tag.TagConfig;
import com.sun.facelets.tag.TagHandler;

/**
 * Tag Handler for tabChangeListener tag
 */
public class TabChangeListenerHandler extends TagHandler {
        private final TagAttribute      type;

        /**
         * @param tagConfig
         */
        public TabChangeListenerHandler(TagConfig tagConfig) {
                super(tagConfig);
                type = getRequiredAttribute("type");
        }

        /* (non-Javadoc)
         * @see com.sun.facelets.FaceletHandler#apply(com.sun.facelets.FaceletContext, javax.faces.component.UIComponent)
         */
        public void apply(FaceletContext faceletContext, UIComponent parent) throws IOException, FacesException, FaceletException, ELException {
                // only process if parent was just created
                if (parent.getParent() == null) {
                        if (parent instanceof HtmlPanelTabbedPane) {
                                String className;
                    if (!type.isLiteral()) {
                       className = type.getValue();
                    } else {
                       className = type.getValue(faceletContext);
                    }
                    TabChangeListener listener = (TabChangeListener) ClassUtils.newInstance(className);
                        ((HtmlPanelTabbedPane)parent).addTabChangeListener(listener);
                        } else {
                                throw new FacesException("Component is noHtmlPanelTabbedPane children");
                }
                }
        }
}

TabChangeListener (last edited 2009-09-20 23:01:37 by localhost)