You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Denis Parhomenko <de...@gmail.com> on 2005/10/03 21:15:07 UTC
facelets and UpdateActionListener
Hi
I want use UpdateActionListener with facelets, but facelets told me that
com.sun.facelets.tag.TagException: /pages/admin/locations/edit.jsp @59,116
<t:updateActionListener> Tag Library supports namespace:
http://myfaces.apache.org/tomahawk, but no tag was defined for name:
updateActionListener
at com.sun.facelets.compiler.CompilationManager.pushTag(
CompilationManager.java:155)
at com.sun.facelets.compiler.SAXCompiler$CompilationHandler.startElement(
SAXCompiler.java:175)
As I understand i need add somthing to tomahawk.taglib.xml, but i don't know
what
Deniss
Re: facelets and UpdateActionListener
Posted by Mike Kienenberger <mk...@gmail.com>.
If MyFaces ever delivers facelets support "built-in", it would be
something that MyFaces supplies. UpdateActionListener is not a
component tag, so there's nothing to "rewrite" on the MyFaces side.
It has to be handled with an equivalent facelets TagHandler.
On 10/3/05, Dave Brondsema <da...@brondsema.net> wrote:
> Is this class something that MyFaces should provide and its not?
>
> http://wiki.apache.org/myfaces/Use_Facelets_with_Tomahawk says
> <quote>
> If the Tag class does anything other than providing pass-through getters
> and setters, you will need to write a facelets TagHandler or submit
> patches to MyFaces to "standardize" the tag handler.
> </quote>
>
> Do we need to "standardize" UpdateActionListener? Or is it up to
> Facelets/3rd-party to provide the tag handler?
>
> Andrew robinson wrote:
> > There is no way to do this out of the box. You need to create a tag
> > handler that fills the resposibility of the UpdateActionListenerTag. I
> > have created one. The code is attached. Just change the packages for
> > your needs
> >
> > The XML to register this is:
> > <tag>
> > <tag-name>updateActionListener</tag-name>
> >
> > <handler-class>org.bethanyefree.taghandlers.TomahawkUpdateActionListenerHandler</handler-class>
> > </tag>
> >
> > Just add that to your facelet configuration file for the tomahawk
> > components.
> >
> > On 10/3/05, *Denis Parhomenko* <deniss.parhomenko@gmail.com
> > <ma...@gmail.com>> wrote:
> >
> > Hi
> >
> > I want use UpdateActionListener with facelets, but facelets told me
> > that
> >
> > com.sun.facelets.tag.TagException: /pages/admin/locations/edit.jsp
> > @59,116 <t:updateActionListener> Tag Library supports namespace:
> > http://myfaces.apache.org/tomahawk, but no tag was defined for name:
> > updateActionListener
> > at
> > com.sun.facelets.compiler.CompilationManager.pushTag(CompilationManager.java:155)
> > at
> > com.sun.facelets.compiler.SAXCompiler$CompilationHandler.startElement(SAXCompiler.java:175)
> >
> > As I understand i need add somthing to tomahawk.taglib.xml, but i
> > don't know what
> >
> > Deniss
> >
> >
> >
> > ------------------------------------------------------------------------
> >
> > /**
> > *
> > */
> > package org.bethanyefree.taghandlers;
> >
> > import java.io.IOException;
> >
> > import javax.el.ELException;
> > import javax.faces.FacesException;
> > import javax.faces.application.Application;
> > import javax.faces.component.ActionSource;
> > import javax.faces.component.UIComponent;
> > import javax.faces.convert.Converter;
> > import javax.faces.el.ValueBinding;
> > import javax.faces.event.ActionListener;
> >
> > import org.apache.commons.logging.Log;
> > import org.apache.commons.logging.LogFactory;
> > import org.apache.myfaces.custom.updateactionlistener.UpdateActionListener;
> >
> > 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;
> > import com.sun.facelets.tag.jsf.ComponentConfig;
> >
> > /**
> > * @author andrew
> > *
> > */
> > public class TomahawkUpdateActionListenerHandler
> > extends TagHandler
> > {
> > private static Log logger = LogFactory.getLog(TomahawkUpdateActionListenerHandler.class);
> >
> > private TagAttribute converterAttr;
> > private TagAttribute propertyAttr;
> > private TagAttribute valueAttr;
> >
> > /**
> > * @param config
> > */
> > public TomahawkUpdateActionListenerHandler(ComponentConfig config)
> > {
> > this((TagConfig)config);
> > }
> >
> > /**
> > * @param config
> > */
> > public TomahawkUpdateActionListenerHandler(TagConfig config)
> > {
> > super(config);
> > valueAttr = getRequiredAttribute("value");
> > propertyAttr = getRequiredAttribute("property");
> > converterAttr = getAttribute("converter");
> > }
> >
> > /**
> > * @see com.sun.facelets.FaceletHandler#apply(com.sun.facelets.FaceletContext, javax.faces.component.UIComponent)
> > */
> > public void apply(FaceletContext ctx, UIComponent parent)
> > throws IOException, FacesException, FaceletException, ELException
> > {
> > logger.error("Apply called. Component: " + parent);
> > ActionSource actionSource = (ActionSource)parent;
> >
> > if (sourceHasProperty(actionSource))
> > return;
> >
> > UpdateActionListener al = new UpdateActionListener();
> >
> > if (converterAttr != null)
> > al.setConverter((Converter)converterAttr.getObject(ctx));
> >
> > Application app = ctx.getFacesContext().getApplication();
> > ValueBinding vb = app.createValueBinding(valueAttr.getValue());
> > al.setValueBinding(vb);
> > vb = app.createValueBinding(propertyAttr.getValue());
> > al.setPropertyBinding(vb);
> > actionSource.addActionListener(al);
> > }
> >
> > private boolean sourceHasProperty(ActionSource source)
> > {
> > for (ActionListener listener : source.getActionListeners())
> > {
> > if (listener instanceof UpdateActionListener == false) continue;
> > UpdateActionListener al = (UpdateActionListener)listener;
> > if (al.getPropertyBinding().getExpressionString().equals(
> > this.propertyAttr.getValue()))
> > {
> > logger.debug("Action listener already has a listener for " +
> > this.propertyAttr.getValue());
> > return true;
> > }
> > }
> > logger.debug("Action listener for property is not present. Property: " +
> > this.propertyAttr.getValue());
> > return false;
> > }
> > }
>
>
> --
> Dave Brondsema
> Software Developer
> Cornerstone University
>
>
>
Re: facelets and UpdateActionListener
Posted by Dave Brondsema <da...@brondsema.net>.
Is this class something that MyFaces should provide and its not?
http://wiki.apache.org/myfaces/Use_Facelets_with_Tomahawk says
<quote>
If the Tag class does anything other than providing pass-through getters
and setters, you will need to write a facelets TagHandler or submit
patches to MyFaces to "standardize" the tag handler.
</quote>
Do we need to "standardize" UpdateActionListener? Or is it up to
Facelets/3rd-party to provide the tag handler?
Andrew robinson wrote:
> There is no way to do this out of the box. You need to create a tag
> handler that fills the resposibility of the UpdateActionListenerTag. I
> have created one. The code is attached. Just change the packages for
> your needs
>
> The XML to register this is:
> <tag>
> <tag-name>updateActionListener</tag-name>
>
> <handler-class>org.bethanyefree.taghandlers.TomahawkUpdateActionListenerHandler</handler-class>
> </tag>
>
> Just add that to your facelet configuration file for the tomahawk
> components.
>
> On 10/3/05, *Denis Parhomenko* <deniss.parhomenko@gmail.com
> <ma...@gmail.com>> wrote:
>
> Hi
>
> I want use UpdateActionListener with facelets, but facelets told me
> that
>
> com.sun.facelets.tag.TagException: /pages/admin/locations/edit.jsp
> @59,116 <t:updateActionListener> Tag Library supports namespace:
> http://myfaces.apache.org/tomahawk, but no tag was defined for name:
> updateActionListener
> at
> com.sun.facelets.compiler.CompilationManager.pushTag(CompilationManager.java:155)
> at
> com.sun.facelets.compiler.SAXCompiler$CompilationHandler.startElement(SAXCompiler.java:175)
>
> As I understand i need add somthing to tomahawk.taglib.xml, but i
> don't know what
>
> Deniss
>
>
>
> ------------------------------------------------------------------------
>
> /**
> *
> */
> package org.bethanyefree.taghandlers;
>
> import java.io.IOException;
>
> import javax.el.ELException;
> import javax.faces.FacesException;
> import javax.faces.application.Application;
> import javax.faces.component.ActionSource;
> import javax.faces.component.UIComponent;
> import javax.faces.convert.Converter;
> import javax.faces.el.ValueBinding;
> import javax.faces.event.ActionListener;
>
> import org.apache.commons.logging.Log;
> import org.apache.commons.logging.LogFactory;
> import org.apache.myfaces.custom.updateactionlistener.UpdateActionListener;
>
> 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;
> import com.sun.facelets.tag.jsf.ComponentConfig;
>
> /**
> * @author andrew
> *
> */
> public class TomahawkUpdateActionListenerHandler
> extends TagHandler
> {
> private static Log logger = LogFactory.getLog(TomahawkUpdateActionListenerHandler.class);
>
> private TagAttribute converterAttr;
> private TagAttribute propertyAttr;
> private TagAttribute valueAttr;
>
> /**
> * @param config
> */
> public TomahawkUpdateActionListenerHandler(ComponentConfig config)
> {
> this((TagConfig)config);
> }
>
> /**
> * @param config
> */
> public TomahawkUpdateActionListenerHandler(TagConfig config)
> {
> super(config);
> valueAttr = getRequiredAttribute("value");
> propertyAttr = getRequiredAttribute("property");
> converterAttr = getAttribute("converter");
> }
>
> /**
> * @see com.sun.facelets.FaceletHandler#apply(com.sun.facelets.FaceletContext, javax.faces.component.UIComponent)
> */
> public void apply(FaceletContext ctx, UIComponent parent)
> throws IOException, FacesException, FaceletException, ELException
> {
> logger.error("Apply called. Component: " + parent);
> ActionSource actionSource = (ActionSource)parent;
>
> if (sourceHasProperty(actionSource))
> return;
>
> UpdateActionListener al = new UpdateActionListener();
>
> if (converterAttr != null)
> al.setConverter((Converter)converterAttr.getObject(ctx));
>
> Application app = ctx.getFacesContext().getApplication();
> ValueBinding vb = app.createValueBinding(valueAttr.getValue());
> al.setValueBinding(vb);
> vb = app.createValueBinding(propertyAttr.getValue());
> al.setPropertyBinding(vb);
> actionSource.addActionListener(al);
> }
>
> private boolean sourceHasProperty(ActionSource source)
> {
> for (ActionListener listener : source.getActionListeners())
> {
> if (listener instanceof UpdateActionListener == false) continue;
> UpdateActionListener al = (UpdateActionListener)listener;
> if (al.getPropertyBinding().getExpressionString().equals(
> this.propertyAttr.getValue()))
> {
> logger.debug("Action listener already has a listener for " +
> this.propertyAttr.getValue());
> return true;
> }
> }
> logger.debug("Action listener for property is not present. Property: " +
> this.propertyAttr.getValue());
> return false;
> }
> }
--
Dave Brondsema
Software Developer
Cornerstone University
Re: facelets and UpdateActionListener
Posted by Andrew robinson <an...@gmail.com>.
There is no way to do this out of the box. You need to create a tag handler
that fills the resposibility of the UpdateActionListenerTag. I have created
one. The code is attached. Just change the packages for your needs
The XML to register this is:
<tag>
<tag-name>updateActionListener</tag-name>
<handler-class>
org.bethanyefree.taghandlers.TomahawkUpdateActionListenerHandler
</handler-class>
</tag>
Just add that to your facelet configuration file for the tomahawk
components.
On 10/3/05, Denis Parhomenko <de...@gmail.com> wrote:
>
> Hi
>
> I want use UpdateActionListener with facelets, but facelets told me that
>
> com.sun.facelets.tag.TagException: /pages/admin/locations/edit.jsp @59,116
> <t:updateActionListener> Tag Library supports namespace:
> http://myfaces.apache.org/tomahawk, but no tag was defined for name:
> updateActionListener
> at com.sun.facelets.compiler.CompilationManager.pushTag(
> CompilationManager.java:155)
> at com.sun.facelets.compiler.SAXCompiler$CompilationHandler.startElement(
> SAXCompiler.java:175)
>
> As I understand i need add somthing to tomahawk.taglib.xml, but i don't
> know what
>
> Deniss