myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Myfaces Wiki] Update of "TagHandler" by SebastienLever
Date Thu, 22 Feb 2007 17:30:16 GMT
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 SebastienLever:
http://wiki.apache.org/myfaces/TagHandler

------------------------------------------------------------------------------
  
  If it concerns a JSP tag, you'll have to write a facelets tag handler for it.
  
- here are existing tag handlers implementations
+ here are existing tag handlers definitions:
+  - Self:tabChangeListener
  
+  - Self:treeHandler
- === tabChangeListener ===
- __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");
- 	        }
- 		}
- 	}
- }
- }}}
- 

Mime
View raw message