Thanks, Ryan. All tests passing. Code committed.
Ed: not sure we confirmed: Would you like to see a JSP
implementation of this? I can try to get that done and committed by
Monday, but I can't promise.
On Feb 6, 2009, at 5:05 PM, Ryan Lubke wrote:
> Ensure the tests cover the no-arg and arg cases then r=rlubke.
>
> Jason Lee wrote:
>> Here is the change bundle that should fix any outstanding bugs in
>> the f:event implementation, as well as bring it up to date with the
>> current state of the spec. All unit tests are (finally) passing.
>>
>> * Moved Util.loadClass and related code to
>> NamedEventManager.getNamedEvent() for more consistent error checking
>> * Add Class.isAssignable check
>> * Add no-arg method option to the "listener" method
>> * Add code to the systest to exercise the FQCN code path
>> * Code clean up
>>
>> Index: jsf-ri/src/com/sun/faces/facelets/tag/jsf/core/
>> EventHandler.java
>> ===================================================================
>> --- jsf-ri/src/com/sun/faces/facelets/tag/jsf/core/
>> EventHandler.java (revision 6428)
>> +++ jsf-ri/src/com/sun/faces/facelets/tag/jsf/core/
>> EventHandler.java (working copy)
>> @@ -10,9 +10,9 @@
>> import java.io.IOException;
>> import java.io.Serializable;
>> -import javax.el.ELContext;
>> import javax.el.ELException;
>> import javax.el.MethodExpression;
>> +import javax.el.MethodNotFoundException;
>> import javax.faces.FacesException;
>> import javax.faces.context.FacesContext;
>> import javax.faces.component.UIComponent;
>> @@ -48,25 +48,13 @@
>> }
>> protected Class<? extends SystemEvent>
>> getEventClass(FaceletContext ctx) {
>> - Class<? extends SystemEvent> clazz = null;
>> String eventType = (String)
>> this.type.getValueExpression(ctx, String.class).getValue(ctx);
>> if (eventType == null) {
>> throw new FacesException("Attribute 'type' can not be
>> null");
>> }
>> - ApplicationAssociate associate =
>> -
>> ApplicationAssociate
>> .getInstance(ctx.getFacesContext().getExternalContext());
>> - NamedEventManager nem = associate.getNamedEventManager();
>> - clazz = nem.getNamedEvent(eventType);
>> - if (clazz == null) {
>> - try {
>> - clazz = Util.loadClass(eventType, this);
>> - } catch (ClassNotFoundException ex) {
>> - throw new FacesException ("An unknown event type
>> was specified: " + eventType);
>> - }
>> - }
>> -
>> - return clazz;
>> + return
>> ApplicationAssociate
>> .getInstance(ctx.getFacesContext().getExternalContext())
>> + .getNamedEventManager().getNamedEvent(eventType);
>> }
>> }
>> @@ -86,6 +74,12 @@
>> }
>> public void processEvent(ComponentSystemEvent event) throws
>> AbortProcessingException {
>> -
>> action.invoke(FacesContext.getCurrentInstance().getELContext(), new
>> Object[]{event});
>> + try{
>> + // Attempt to call public void
>> method(ComponentSystemEvent event)
>> +
>> action.invoke(FacesContext.getCurrentInstance().getELContext(), new
>> Object[]{event});
>> + } catch (MethodNotFoundException mnfe) {
>> + // Attempt to call public void method()
>> +
>> action.invoke(FacesContext.getCurrentInstance().getELContext(), new
>> Object[]{});
>> + }
>> }
>> }
>> \ No newline at end of file
>> Index: jsf-ri/src/com/sun/faces/application/NamedEventManager.java
>> ===================================================================
>> --- jsf-ri/src/com/sun/faces/application/NamedEventManager.java
>> (revision 6428)
>> +++ jsf-ri/src/com/sun/faces/application/NamedEventManager.java
>> (working copy)
>> @@ -4,15 +4,18 @@
>> */
>> package com.sun.faces.application;
>> +import com.sun.faces.util.Util;
>> import java.util.HashSet;
>> import java.util.Map;
>> import java.util.Set;
>> import java.util.concurrent.ConcurrentHashMap;
>> +import javax.faces.FacesException;
>> import javax.faces.event.AfterAddToParentEvent;
>> import javax.faces.event.AfterAddToViewEvent;
>> import javax.faces.event.AfterValidateEvent;
>> import javax.faces.event.BeforeRenderEvent;
>> import javax.faces.event.BeforeValidateEvent;
>> +import javax.faces.event.ComponentSystemEvent;
>> import javax.faces.event.SystemEvent;
>> /**
>> @@ -45,6 +48,17 @@
>> public Class<? extends SystemEvent> getNamedEvent(String name) {
>> String foo = namedEvents.toString();
>> Class<? extends SystemEvent> namedEvent =
>> namedEvents.get(name);
>> + if (namedEvent == null) {
>> + try {
>> + namedEvent = Util.loadClass(name, this);
>> + } catch (ClassNotFoundException ex) {
>> + throw new FacesException ("An unknown event type
>> was specified: " + name, ex);
>> + }
>> + }
>> + if (!
>> ComponentSystemEvent.class.isAssignableFrom(namedEvent)) {
>> + throw new ClassCastException();
>> + }
>> +
>> return namedEvent;
>> }
>> Index: jsf-ri/systest/src/com/sun/faces/annotation/
>> AnnotationTestBean.java
>> ===================================================================
>> --- jsf-ri/systest/src/com/sun/faces/annotation/
>> AnnotationTestBean.java (revision 6428)
>> +++ jsf-ri/systest/src/com/sun/faces/annotation/
>> AnnotationTestBean.java (working copy)
>> @@ -172,8 +172,12 @@
>> // Test short name
>>
>> assertNotNull
>> (ApplicationAssociate.getInstance(ctx.getExternalContext())
>> .getNamedEventManager
>> ().getNamedEvent
>> ("com.sun.faces.annotation.anotherAnnotatedComponentSystem"));
>> + // Test FQCN
>>
>> assertNotNull
>> (ApplicationAssociate.getInstance(ctx.getExternalContext())
>> +
>> .getNamedEventManager
>> ().getNamedEvent(AnnotatedComponentSystemEvent.class.getName()));
>> +
>> assertNotNull
>> (ApplicationAssociate.getInstance(ctx.getExternalContext())
>> .getNamedEventManager
>> ().getNamedEvent("explicitEventName"));
>> +
>> }
>> private void assertNotNull(Object v) {
>>
>>
>> <http://www.java.com> * Jason Lee *
>> Senior Java Developer
>> GlassFish Administration Console
>>
>> *Sun Microsystems, Inc.*
>> Phone x31197/+1 405-343-1964
>> Email jasondlee_at_sun.com <mailto:jasondlee_at_sun.com>
>> Blog http://blogs.sun.com/jasondlee
>> Blog http://blogs.steeplesoft.com
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_javaserverfaces.dev.java.net
> For additional commands, e-mail: dev-help_at_javaserverfaces.dev.java.net
>
Jason Lee, SCJP
Senior Java Developer, Sun Microsystems
Mojarra and Mojarra Scales Dev Team
https://mojarra.dev.java.net
https://scales.dev.java.net
http://blogs.steeplesoft.com