Are you using Facelets?
If yes:
You have to register a handler-class in the tomahawk.taglib.xml:
<tag>
<tag-name>tabChangeListener</tag-name>
<handler-class>facelets.TabChangeListenerHandler</handler-class>
</tag>
And then include the Handler Class with in your libraries:
/*
* Copyright 2006 DBS Servicios Informáticos, S.L. All rights reserved.
* Propiedad de DBS Servicios Informáticos.
*/
package facelets;
import com.sun.facelets.tag.TagHandler;
import com.sun.facelets.tag.TagAttribute;
import com.sun.facelets.tag.TagConfig;
import com.sun.facelets.FaceletContext;
import com.sun.facelets.FaceletException;
import java.io.IOException;
import javax.faces.FacesException;
import javax.faces.component.UIComponent;
import javax.el.ELException;
import org.apache.myfaces.custom.tabbedpane.HtmlPanelTabbedPane;
import org.apache.myfaces.custom.tabbedpane.TabChangeListener;
import org.apache.myfaces.shared_tomahawk.util.ClassUtils;
/**
* @author Nacho Estrada <nacho.estrada -at- dbs.es> (website http://www.dbs.es)
*
*/
public class TabChangeListenerHandler extends TagHandler {
private final TagAttribute type;
public TabChangeListenerHandler(TagConfig config) {
super(config);
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 no
HtmlPanelTabbedPane children");
}
}
}
}
Using it:
<t:tabChangeListener type="es.dbs.ysf.ListenerExample" /> as
<t:panelTabbedPane /> children.
The attribute type must specify the name of a class implementing
TabChangeListener interface.
Hope be useful.
Nacho Estrada.
srivalli2006 <neelamsrivalli <at> gmail.com> writes:
Hi ,
I am using tomahawk <t:panelTabbedPane/> tag. However I would like an action
event to be fired and would like to refresh my page on clicking a particular
tab(i.e.<t:panelTab />) on the pane.On searching google I found
<t:tabChangeListener/>.But i dont now how to use it.If anyone has idea of
how to use it or any other alternative solution , it would be of great
help.This is an emergency.
Thanks and Regards
Srivalli Neelam
Mr Arvind Pandey <arvindspandey <at> yahoo.co.in> writes:
Hi,
use like this ....
........
...........
........
..........
t:panelTabbedPane styleClass="tabbedpane_css"
align="center" width="90%"
selectedIndex="#{tabbedPaneBean.tabIndex}"
serverSideTabSwitch="true" >
t:tabChangeListener type="com.abc.xyz.TabListener"/>
...........
.........
..........
// TabListener class is as below :
package com.abc.xyz;
public class TabListener implements TabChangeListener{
public TabListener() {
super();
//Write your own code.
}
public void processTabChange(TabChangeEvent
event) throws AbortProcessingException {
//you can use evnt.getNewTabIndex() to remain
//on the same tab after refresh.
........
........
//Now you can get the latest data from DB if
//required.
.........
.......
//Now refresh the page as below :
FacesContext context =
FacesContext.getCurrentInstance();
Application application =
context.getApplication();
//this.refreshPage() ...I have writtent for refreshing
this.refreshPage(context, application,
"/current-page.jsp", "currentPage");
}
}
public void refreshPage(FacesContext facesContext,
Application application,
String viewId, String outcome) {
LifecycleFactory lFactory = (LifecycleFactory)
FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
Lifecycle lifecycle =
lFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
ViewHandler viewHandler =
application.getViewHandler();
// specify what page you want to pretend to "come
from"; normally
// an empty string is ok
UIViewRoot view =
viewHandler.createView(facesContext, viewId);
facesContext.setViewRoot(view);
// specify what outcome value you want to use for
navigation
NavigationHandler navigationHandler =
application.getNavigationHandler();
navigationHandler.handleNavigation(facesContext,
null, outcome);
lifecycle.render(facesContext);
}
Also modify your navigation file i.e. faces-config.xml
from outcome....currentPage......
to view id ...currentPage.jsp....
regards...
Arvind
--- srivalli2006 <neelamsrivalli <at> gmail.com> wrote:
>
> Hi ,
>
> I am using tomahawk <t:panelTabbedPane/> tag.
> However I would like an action
> event to be fired and would like to refresh my page
> on clicking a particular
> tab(i.e.<t:panelTab />) on the pane.On searching
> google I found
> <t:tabChangeListener/>.But i dont now how to use
> it.If anyone has idea of
> how to use it or any other alternative solution , it
> would be of great
> help.This is an emergency.
>
> Thanks and Regards
> Srivalli Neelam
> --
> View this message in context:
>
http://www.nabble.com/using-Tomahawk-%3Ct%3AtabChangeListener-%3E-with-%3Ct%3ApanelTab-%3E-tf2707427.html#a7548550
> Sent from the My Faces - Dev mailing list archive at
> Nabble.com.
>
>
__________________________________________________________
Yahoo! India Answers: Share what you know. Learn something new
http://in.answers.yahoo.com/