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/02/22 18:30:52 UTC
[Myfaces Wiki] Update of "tabChangeListener" by SebastienLever
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/tabChangeListener
New page:
=== 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");
}
}
}
}
}}}