You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by Matthias Wessendorf <ma...@apache.org> on 2006/06/18 20:55:01 UTC
Re: svn commit: r415171 - in /myfaces/core/branches/jsf12/impl/src/main: java/org/apache/myfaces/taglib/core/ java/org/apache/myfaces/util/ tld/
Hey Dennis,
interesting. Yesterday evening I assigned that guy to me
http://issues.apache.org/jira/browse/MYFACES-1240
I started to implement it and I was about to commit,
and now I see your commit.
I think when two are doing the same, it is a waste of effort :-)
We should cordinate it a bit better, right?
For JSF 1.2 there is special component
http://tinyurl.com/qjd6y
Regards,
Matthias
On 6/18/06, dennisbyrne@apache.org <de...@apache.org> wrote:
> Author: dennisbyrne
> Date: Sun Jun 18 11:39:08 2006
> New Revision: 415171
>
> URL: http://svn.apache.org/viewvc?rev=415171&view=rev
> Log:
> created SetPropertyActionListenerTag and it's ActionListener.
> placed f:setPropertyActionListener in TLD
> added Java 5 to DebugUtils
>
> Added:
> myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/taglib/core/SetPropertyActionListener.java
> myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/taglib/core/SetPropertyActionListenerTag.java
> Modified:
> myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/util/DebugUtils.java
> myfaces/core/branches/jsf12/impl/src/main/tld/myfaces_core.tld
>
> Added: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/taglib/core/SetPropertyActionListener.java
> URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/taglib/core/SetPropertyActionListener.java?rev=415171&view=auto
> ==============================================================================
> --- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/taglib/core/SetPropertyActionListener.java (added)
> +++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/taglib/core/SetPropertyActionListener.java Sun Jun 18 11:39:08 2006
> @@ -0,0 +1,103 @@
> +package org.apache.myfaces.taglib.core;
> +
> +import javax.el.ELContext;
> +import javax.el.ValueExpression;
> +import javax.faces.component.StateHolder;
> +import javax.faces.context.FacesContext;
> +import javax.faces.event.AbortProcessingException;
> +import javax.faces.event.ActionEvent;
> +import javax.faces.event.ActionListener;
> +
> +/**
> + * TODO this really needs to be under javax.faces.*
> + *
> + * @author Dennis Byrne
> + * @since 1.2
> + */
> +
> +public class SetPropertyActionListener implements ActionListener, StateHolder
> +{
> +
> + private ValueExpression target;
> +
> + private ValueExpression value;
> +
> + private boolean _transient ;
> +
> + public SetPropertyActionListener(){}
> +
> + public SetPropertyActionListener(ValueExpression target, ValueExpression value)
> + {
> + this.target = target;
> + this.value = value;
> + }
> +
> + public void processAction(ActionEvent actionEvent) throws AbortProcessingException
> + {
> +
> + if( target == null )
> + throw new AbortProcessingException("@target has not been set");
> +
> + if( value == null )
> + throw new AbortProcessingException("@value has not been set");
> +
> + FacesContext ctx = FacesContext.getCurrentInstance();
> +
> + if( ctx == null )
> + throw new AbortProcessingException("FacesContext ctx is null");
> +
> + ELContext ectx = ctx.getELContext();
> +
> + if( ectx == null )
> + throw new AbortProcessingException("ELContext ectx is null");
> +
> + target.setValue(ectx, value.getValue(ectx));
> +
> + }
> +
> + public Object saveState(FacesContext context)
> + {
> + Object[] state = new Object[2];
> + state[0] = target;
> + state[1] = value;
> + return state;
> + }
> +
> + public void restoreState(FacesContext context, Object state)
> + {
> + Object[] values = new Object[2];
> + target = (ValueExpression) values[0];
> + value = (ValueExpression) values[1];
> + }
> +
> + public boolean isTransient()
> + {
> + return _transient;
> + }
> +
> + public void setTransient(boolean _transient)
> + {
> + this._transient = _transient;
> + }
> +
> + public ValueExpression getTarget()
> + {
> + return target;
> + }
> +
> + public void setTarget(ValueExpression target)
> + {
> + this.target = target;
> + }
> +
> + public ValueExpression getValue()
> + {
> + return value;
> + }
> +
> + public void setValue(ValueExpression value)
> + {
> + this.value = value;
> + }
> +
> +}
>
> Added: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/taglib/core/SetPropertyActionListenerTag.java
> URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/taglib/core/SetPropertyActionListenerTag.java?rev=415171&view=auto
> ==============================================================================
> --- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/taglib/core/SetPropertyActionListenerTag.java (added)
> +++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/taglib/core/SetPropertyActionListenerTag.java Sun Jun 18 11:39:08 2006
> @@ -0,0 +1,97 @@
> +package org.apache.myfaces.taglib.core;
> +
> +import javax.el.ValueExpression;
> +import javax.faces.component.ActionSource;
> +import javax.faces.component.UIComponent;
> +import javax.faces.event.ActionListener;
> +import javax.faces.webapp.UIComponentClassicTagBase;
> +import javax.servlet.jsp.JspException;
> +import javax.servlet.jsp.tagext.TagSupport;
> +
> +import org.apache.commons.logging.Log;
> +import org.apache.commons.logging.LogFactory;
> +
> +/**
> + * @author Dennis Byrne
> + * @since 1.2
> + */
> +
> +public class SetPropertyActionListenerTag extends TagSupport
> +{
> +
> + private static final Log log = LogFactory.getLog(SetPropertyActionListenerTag.class);
> +
> + private ValueExpression target;
> +
> + private ValueExpression value;
> +
> + public int doStartTag() throws JspException
> + {
> +
> + if(log.isDebugEnabled())
> + log.debug("JSF 1.2 Spec : Create a new instance of the ActionListener");
> +
> + ActionListener actionListener = new SetPropertyActionListener(target, value);
> +
> + UIComponentClassicTagBase tag = UIComponentClassicTagBase.getParentUIComponentClassicTagBase(pageContext);
> +
> + if(tag == null)
> + throw new JspException("Could not find a " +
> + "parent UIComponentClassicTagBase ... is this " +
> + "tag in a child of a UIComponentClassicTagBase?");
> +
> + if(tag.getCreated())
> + {
> +
> + UIComponent component = tag.getComponentInstance();
> +
> + if(component == null)
> + throw new JspException(" Could not locate a UIComponent " +
> + "for a UIComponentClassicTagBase w/ a " +
> + "JSP id of " + tag.getJspId());
> +
> + if( ! ( component instanceof ActionSource ) )
> + throw new JspException("Component w/ id of " + component.getId()
> + + " is associated w/ a tag w/ JSP id of " + tag.getJspId()
> + + ". This component is of type " + component.getClass()
> + + ", which is not an " + ActionSource.class );
> +
> + if(log.isDebugEnabled())
> + log.debug(" ... register it with the UIComponent " +
> + "instance associated with our most immediately " +
> + "surrounding UIComponentTagBase");
> +
> + ((ActionSource)component).addActionListener(actionListener);
> +
> + }
> +
> + return SKIP_BODY;
> + }
> +
> + public ValueExpression getTarget()
> + {
> + return target;
> + }
> +
> + public void setTarget(ValueExpression target)
> + {
> + this.target = target;
> + }
> +
> + public ValueExpression getValue()
> + {
> + return value;
> + }
> +
> + public void setValue(ValueExpression value)
> + {
> + this.value = value;
> + }
> +
> + public void release()
> + {
> + target = null;
> + value = null;
> + }
> +
> +}
>
> Modified: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/util/DebugUtils.java
> URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/util/DebugUtils.java?rev=415171&r1=415170&r2=415171&view=diff
> ==============================================================================
> --- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/util/DebugUtils.java (original)
> +++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/util/DebugUtils.java Sun Jun 18 11:39:08 2006
> @@ -48,10 +48,10 @@
> private static final Log log = LogFactory.getLog(DebugUtils.class);
>
> //Attributes that should not be printed
> - private static final HashSet IGNORE_ATTRIBUTES;
> + private static final HashSet<String> IGNORE_ATTRIBUTES;
> static
> {
> - IGNORE_ATTRIBUTES = new HashSet();
> + IGNORE_ATTRIBUTES = new HashSet<String>();
> IGNORE_ATTRIBUTES.add("attributes");
> IGNORE_ATTRIBUTES.add("children");
> IGNORE_ATTRIBUTES.add("childCount");
>
> Modified: myfaces/core/branches/jsf12/impl/src/main/tld/myfaces_core.tld
> URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/tld/myfaces_core.tld?rev=415171&r1=415170&r2=415171&view=diff
> ==============================================================================
> --- myfaces/core/branches/jsf12/impl/src/main/tld/myfaces_core.tld (original)
> +++ myfaces/core/branches/jsf12/impl/src/main/tld/myfaces_core.tld Sun Jun 18 11:39:08 2006
> @@ -601,5 +601,20 @@
> </attribute>
> </tag>
>
> + <!-- setPropertyActionListener -->
> +
> + <tag>
> + <name>setPropertyActionListener</name>
> + <tag-class>org.apache.myfaces.taglib.core.SetPropertyActionListenerTag</tag-class>
> + <body-content>empty</body-content>
> + <attribute>
> + <name>target</name>
> + <required>true</required>
> + </attribute>
> + <attribute>
> + <name>value</name>
> + <required>true</required>
> + </attribute>
> + </tag>
>
> </taglib>
>
>
>
--
Matthias Wessendorf
Aechterhoek 18
48282 Emsdetten
blog: http://jroller.com/page/mwessendorf
mail: mwessendorf-at-gmail-dot-com
Re: svn commit: r415171 - in /myfaces/core/branches/jsf12/impl/src/main: java/org/apache/myfaces/taglib/core/ java/org/apache/myfaces/util/ tld/
Posted by Matthias Wessendorf <ma...@apache.org>.
the RI has the pattern that the ActionListener inside the taglib_core package.
I don't like this. I'll remove the SetPropertyActionListener clazz to
o.a.m.event.
-Matthias
On 6/18/06, Matthias Wessendorf <ma...@apache.org> wrote:
> Hey Dennis,
>
> interesting. Yesterday evening I assigned that guy to me
>
> http://issues.apache.org/jira/browse/MYFACES-1240
>
> I started to implement it and I was about to commit,
> and now I see your commit.
>
> I think when two are doing the same, it is a waste of effort :-)
>
> We should cordinate it a bit better, right?
>
> For JSF 1.2 there is special component
>
> http://tinyurl.com/qjd6y
>
> Regards,
> Matthias
>
> On 6/18/06, dennisbyrne@apache.org <de...@apache.org> wrote:
> > Author: dennisbyrne
> > Date: Sun Jun 18 11:39:08 2006
> > New Revision: 415171
> >
> > URL: http://svn.apache.org/viewvc?rev=415171&view=rev
> > Log:
> > created SetPropertyActionListenerTag and it's ActionListener.
> > placed f:setPropertyActionListener in TLD
> > added Java 5 to DebugUtils
> >
> > Added:
> > myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/taglib/core/SetPropertyActionListener.java
> > myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/taglib/core/SetPropertyActionListenerTag.java
> > Modified:
> > myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/util/DebugUtils.java
> > myfaces/core/branches/jsf12/impl/src/main/tld/myfaces_core.tld
> >
> > Added: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/taglib/core/SetPropertyActionListener.java
> > URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/taglib/core/SetPropertyActionListener.java?rev=415171&view=auto
> > ==============================================================================
> > --- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/taglib/core/SetPropertyActionListener.java (added)
> > +++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/taglib/core/SetPropertyActionListener.java Sun Jun 18 11:39:08 2006
> > @@ -0,0 +1,103 @@
> > +package org.apache.myfaces.taglib.core;
> > +
> > +import javax.el.ELContext;
> > +import javax.el.ValueExpression;
> > +import javax.faces.component.StateHolder;
> > +import javax.faces.context.FacesContext;
> > +import javax.faces.event.AbortProcessingException;
> > +import javax.faces.event.ActionEvent;
> > +import javax.faces.event.ActionListener;
> > +
> > +/**
> > + * TODO this really needs to be under javax.faces.*
> > + *
> > + * @author Dennis Byrne
> > + * @since 1.2
> > + */
> > +
> > +public class SetPropertyActionListener implements ActionListener, StateHolder
> > +{
> > +
> > + private ValueExpression target;
> > +
> > + private ValueExpression value;
> > +
> > + private boolean _transient ;
> > +
> > + public SetPropertyActionListener(){}
> > +
> > + public SetPropertyActionListener(ValueExpression target, ValueExpression value)
> > + {
> > + this.target = target;
> > + this.value = value;
> > + }
> > +
> > + public void processAction(ActionEvent actionEvent) throws AbortProcessingException
> > + {
> > +
> > + if( target == null )
> > + throw new AbortProcessingException("@target has not been set");
> > +
> > + if( value == null )
> > + throw new AbortProcessingException("@value has not been set");
> > +
> > + FacesContext ctx = FacesContext.getCurrentInstance();
> > +
> > + if( ctx == null )
> > + throw new AbortProcessingException("FacesContext ctx is null");
> > +
> > + ELContext ectx = ctx.getELContext();
> > +
> > + if( ectx == null )
> > + throw new AbortProcessingException("ELContext ectx is null");
> > +
> > + target.setValue(ectx, value.getValue(ectx));
> > +
> > + }
> > +
> > + public Object saveState(FacesContext context)
> > + {
> > + Object[] state = new Object[2];
> > + state[0] = target;
> > + state[1] = value;
> > + return state;
> > + }
> > +
> > + public void restoreState(FacesContext context, Object state)
> > + {
> > + Object[] values = new Object[2];
> > + target = (ValueExpression) values[0];
> > + value = (ValueExpression) values[1];
> > + }
> > +
> > + public boolean isTransient()
> > + {
> > + return _transient;
> > + }
> > +
> > + public void setTransient(boolean _transient)
> > + {
> > + this._transient = _transient;
> > + }
> > +
> > + public ValueExpression getTarget()
> > + {
> > + return target;
> > + }
> > +
> > + public void setTarget(ValueExpression target)
> > + {
> > + this.target = target;
> > + }
> > +
> > + public ValueExpression getValue()
> > + {
> > + return value;
> > + }
> > +
> > + public void setValue(ValueExpression value)
> > + {
> > + this.value = value;
> > + }
> > +
> > +}
> >
> > Added: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/taglib/core/SetPropertyActionListenerTag.java
> > URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/taglib/core/SetPropertyActionListenerTag.java?rev=415171&view=auto
> > ==============================================================================
> > --- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/taglib/core/SetPropertyActionListenerTag.java (added)
> > +++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/taglib/core/SetPropertyActionListenerTag.java Sun Jun 18 11:39:08 2006
> > @@ -0,0 +1,97 @@
> > +package org.apache.myfaces.taglib.core;
> > +
> > +import javax.el.ValueExpression;
> > +import javax.faces.component.ActionSource;
> > +import javax.faces.component.UIComponent;
> > +import javax.faces.event.ActionListener;
> > +import javax.faces.webapp.UIComponentClassicTagBase;
> > +import javax.servlet.jsp.JspException;
> > +import javax.servlet.jsp.tagext.TagSupport;
> > +
> > +import org.apache.commons.logging.Log;
> > +import org.apache.commons.logging.LogFactory;
> > +
> > +/**
> > + * @author Dennis Byrne
> > + * @since 1.2
> > + */
> > +
> > +public class SetPropertyActionListenerTag extends TagSupport
> > +{
> > +
> > + private static final Log log = LogFactory.getLog(SetPropertyActionListenerTag.class);
> > +
> > + private ValueExpression target;
> > +
> > + private ValueExpression value;
> > +
> > + public int doStartTag() throws JspException
> > + {
> > +
> > + if(log.isDebugEnabled())
> > + log.debug("JSF 1.2 Spec : Create a new instance of the ActionListener");
> > +
> > + ActionListener actionListener = new SetPropertyActionListener(target, value);
> > +
> > + UIComponentClassicTagBase tag = UIComponentClassicTagBase.getParentUIComponentClassicTagBase(pageContext);
> > +
> > + if(tag == null)
> > + throw new JspException("Could not find a " +
> > + "parent UIComponentClassicTagBase ... is this " +
> > + "tag in a child of a UIComponentClassicTagBase?");
> > +
> > + if(tag.getCreated())
> > + {
> > +
> > + UIComponent component = tag.getComponentInstance();
> > +
> > + if(component == null)
> > + throw new JspException(" Could not locate a UIComponent " +
> > + "for a UIComponentClassicTagBase w/ a " +
> > + "JSP id of " + tag.getJspId());
> > +
> > + if( ! ( component instanceof ActionSource ) )
> > + throw new JspException("Component w/ id of " + component.getId()
> > + + " is associated w/ a tag w/ JSP id of " + tag.getJspId()
> > + + ". This component is of type " + component.getClass()
> > + + ", which is not an " + ActionSource.class );
> > +
> > + if(log.isDebugEnabled())
> > + log.debug(" ... register it with the UIComponent " +
> > + "instance associated with our most immediately " +
> > + "surrounding UIComponentTagBase");
> > +
> > + ((ActionSource)component).addActionListener(actionListener);
> > +
> > + }
> > +
> > + return SKIP_BODY;
> > + }
> > +
> > + public ValueExpression getTarget()
> > + {
> > + return target;
> > + }
> > +
> > + public void setTarget(ValueExpression target)
> > + {
> > + this.target = target;
> > + }
> > +
> > + public ValueExpression getValue()
> > + {
> > + return value;
> > + }
> > +
> > + public void setValue(ValueExpression value)
> > + {
> > + this.value = value;
> > + }
> > +
> > + public void release()
> > + {
> > + target = null;
> > + value = null;
> > + }
> > +
> > +}
> >
> > Modified: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/util/DebugUtils.java
> > URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/util/DebugUtils.java?rev=415171&r1=415170&r2=415171&view=diff
> > ==============================================================================
> > --- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/util/DebugUtils.java (original)
> > +++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/util/DebugUtils.java Sun Jun 18 11:39:08 2006
> > @@ -48,10 +48,10 @@
> > private static final Log log = LogFactory.getLog(DebugUtils.class);
> >
> > //Attributes that should not be printed
> > - private static final HashSet IGNORE_ATTRIBUTES;
> > + private static final HashSet<String> IGNORE_ATTRIBUTES;
> > static
> > {
> > - IGNORE_ATTRIBUTES = new HashSet();
> > + IGNORE_ATTRIBUTES = new HashSet<String>();
> > IGNORE_ATTRIBUTES.add("attributes");
> > IGNORE_ATTRIBUTES.add("children");
> > IGNORE_ATTRIBUTES.add("childCount");
> >
> > Modified: myfaces/core/branches/jsf12/impl/src/main/tld/myfaces_core.tld
> > URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/tld/myfaces_core.tld?rev=415171&r1=415170&r2=415171&view=diff
> > ==============================================================================
> > --- myfaces/core/branches/jsf12/impl/src/main/tld/myfaces_core.tld (original)
> > +++ myfaces/core/branches/jsf12/impl/src/main/tld/myfaces_core.tld Sun Jun 18 11:39:08 2006
> > @@ -601,5 +601,20 @@
> > </attribute>
> > </tag>
> >
> > + <!-- setPropertyActionListener -->
> > +
> > + <tag>
> > + <name>setPropertyActionListener</name>
> > + <tag-class>org.apache.myfaces.taglib.core.SetPropertyActionListenerTag</tag-class>
> > + <body-content>empty</body-content>
> > + <attribute>
> > + <name>target</name>
> > + <required>true</required>
> > + </attribute>
> > + <attribute>
> > + <name>value</name>
> > + <required>true</required>
> > + </attribute>
> > + </tag>
> >
> > </taglib>
> >
> >
> >
>
>
> --
> Matthias Wessendorf
> Aechterhoek 18
> 48282 Emsdetten
> blog: http://jroller.com/page/mwessendorf
> mail: mwessendorf-at-gmail-dot-com
>
--
Matthias Wessendorf
Aechterhoek 18
48282 Emsdetten
blog: http://jroller.com/page/mwessendorf
mail: mwessendorf-at-gmail-dot-com