Yep, caught that when I did a command line build locally. On Fri, Jun 25, 2010 at 8:32 AM, Yunhua Sang <[email protected]> wrote: > Nice job! One thing is LinkDecorationListener was added into test > folder, should be moved to main folder. > > Thanks, > Yunhua > > On Thu, Jun 24, 2010 at 8:05 PM, <[email protected]> wrote: >> Author: hlship >> Date: Fri Jun 25 00:05:48 2010 >> New Revision: 957758 >> >> URL: http://svn.apache.org/viewvc?rev=957758&view=rev >> Log: >> TAP5-1190: Add new page-level events triggered when links are created for a >> page, allowing the page to modify the links (adding new query parameters) >> >> Added: >> >> tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/LinkDecorationListener.java >> (with props) >> Modified: >> >> tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/EventConstants.java >> >> tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/InternalModule.java >> >> Modified: >> tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/EventConstants.java >> URL: >> http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/EventConstants.java?rev=957758&r1=957757&r2=957758&view=diff >> ============================================================================== >> --- >> tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/EventConstants.java >> (original) >> +++ >> tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/EventConstants.java >> Fri Jun 25 00:05:48 2010 >> @@ -15,6 +15,8 @@ >> package org.apache.tapestry5; >> >> import org.apache.tapestry5.corelib.components.BeanEditForm; >> +import org.apache.tapestry5.services.ComponentEventRequestParameters; >> +import org.apache.tapestry5.services.PageRenderRequestParameters; >> >> /** >> * Constant values for common event names fired by Tapestry components. >> @@ -80,7 +82,7 @@ public class EventConstants >> * >> * @see org.apache.tapestry5.corelib.components.Form >> * @deprecated As of 5.2, this event should no longer be used; the Form >> component now fires a {...@link #VALIDATE} >> - * event. >> + * event. For compatibility, validateForm will be >> supported, but may be removed in a future release. >> */ >> public static final String VALIDATE_FORM = "validateForm"; >> >> @@ -178,14 +180,34 @@ public class EventConstants >> * >> * @SINCE 5.1.0.4 >> */ >> - public static final String PROVIDE_COMPLETIONS = "providecompletions"; >> + public static final String PROVIDE_COMPLETIONS = "provideCompletions"; >> >> /** >> * Event triggered by {...@link >> org.apache.tapestry5.corelib.components.Select} component to inform >> * its >> * container that Select's value has changed. >> * >> - * @since 5.2.0.0 >> + * @since 5.2.0 >> + */ >> + public static final String VALUE_CHANGED = "valueChanged"; >> + >> + /** >> + * Event triggered during page render link generation. The first >> context parameter is the {...@link Link} object, the >> + * second is the {...@link PageRenderRequestParameters} from which the >> Link >> + * was created. The event is triggered on the actively rendering page. >> + * >> + * @since 5.2.0 >> */ >> - public static final String VALUE_CHANGED = "valuechanged"; >> + public static final String DECORATE_PAGE_RENDER_LINK = >> "decoratePageRenderLink"; >> + >> + /** >> + * Event triggered during component event link generation. The first >> context parameter is the {...@link Link} object, >> + * the second is the {...@link ComponentEventRequestParameters} from >> which the Link >> + * was created. The event is triggered on the actively rendering page, >> not necessarily the page >> + * containing the component. >> + * >> + * @since 5.2.0 >> + */ >> + public static final String DECORATE_COMPONENT_EVENT_LINK = >> "decoreateComponentEventLink"; >> + >> } >> >> Modified: >> tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/InternalModule.java >> URL: >> http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/InternalModule.java?rev=957758&r1=957757&r2=957758&view=diff >> ============================================================================== >> --- >> tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/InternalModule.java >> (original) >> +++ >> tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/InternalModule.java >> Fri Jun 25 00:05:48 2010 >> @@ -23,6 +23,7 @@ import org.apache.tapestry5.internal.ser >> import >> org.apache.tapestry5.internal.structure.ComponentPageElementResourcesSource; >> import >> org.apache.tapestry5.internal.structure.ComponentPageElementResourcesSourceImpl; >> import org.apache.tapestry5.ioc.ObjectLocator; >> +import org.apache.tapestry5.ioc.OrderedConfiguration; >> import org.apache.tapestry5.ioc.ScopeConstants; >> import org.apache.tapestry5.ioc.ServiceBinder; >> import org.apache.tapestry5.ioc.annotations.Autobuild; >> @@ -36,16 +37,7 @@ import org.apache.tapestry5.ioc.services >> import org.apache.tapestry5.ioc.services.ClasspathURLConverter; >> import org.apache.tapestry5.ioc.services.PerthreadManager; >> import org.apache.tapestry5.ioc.services.PropertyShadowBuilder; >> -import org.apache.tapestry5.services.ComponentClasses; >> -import org.apache.tapestry5.services.ComponentLayer; >> -import org.apache.tapestry5.services.ComponentMessages; >> -import org.apache.tapestry5.services.ComponentTemplates; >> -import org.apache.tapestry5.services.Core; >> -import org.apache.tapestry5.services.InvalidationEventHub; >> -import org.apache.tapestry5.services.LocalizationSetter; >> -import org.apache.tapestry5.services.RequestGlobals; >> -import org.apache.tapestry5.services.ResponseCompressionAnalyzer; >> -import org.apache.tapestry5.services.UpdateListenerHub; >> +import org.apache.tapestry5.services.*; >> import org.apache.tapestry5.services.templates.ComponentTemplateLocator; >> import org.slf4j.Logger; >> >> @@ -275,4 +267,18 @@ public class InternalModule >> >> return service; >> } >> + >> + /** >> + * Contributes: >> + * <dl> >> + * <dt>LinkDecoration (instance of {...@link >> LinkDecorationListener})</dt> >> + * <dd>Triggers events for notifications about links</dd> >> + * <dl> >> + * >> + * @since 5.2.0 >> + */ >> + public static void >> contributeLinkSource(OrderedConfiguration<LinkCreationListener2> >> configuration) >> + { >> + configuration.addInstance("LinkDecoration", >> LinkDecorationListener.class); >> + } >> } >> >> Added: >> tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/LinkDecorationListener.java >> URL: >> http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/LinkDecorationListener.java?rev=957758&view=auto >> ============================================================================== >> --- >> tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/LinkDecorationListener.java >> (added) >> +++ >> tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/LinkDecorationListener.java >> Fri Jun 25 00:05:48 2010 >> @@ -0,0 +1,73 @@ >> +// Copyright 2010 The Apache Software Foundation >> +// >> +// Licensed under the Apache License, Version 2.0 (the "License"); >> +// you may not use this file except in compliance with the License. >> +// You may obtain a copy of the License at >> +// >> +// http://www.apache.org/licenses/LICENSE-2.0 >> +// >> +// Unless required by applicable law or agreed to in writing, software >> +// distributed under the License is distributed on an "AS IS" BASIS, >> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. >> +// See the License for the specific language governing permissions and >> +// limitations under the License. >> + >> +package org.apache.tapestry5.internal.services; >> + >> +import org.apache.tapestry5.EventConstants; >> +import org.apache.tapestry5.Link; >> +import org.apache.tapestry5.model.ComponentModel; >> +import org.apache.tapestry5.runtime.Component; >> +import org.apache.tapestry5.services.ComponentClassResolver; >> +import org.apache.tapestry5.services.ComponentEventRequestParameters; >> +import org.apache.tapestry5.services.ComponentSource; >> +import org.apache.tapestry5.services.LinkCreationListener2; >> +import org.apache.tapestry5.services.PageRenderRequestParameters; >> + >> +/** >> + * A default {...@link LinkCreationListener2} that triggers the {...@link >> EventConstants#DECORATE_COMPONENT_EVENT_LINK} and >> + * {...@link EventConstants#DECORATE_PAGE_RENDER_LINK} events as links are >> generated. >> + * >> + * @since 5.2.0 >> + */ >> +public class LinkDecorationListener implements LinkCreationListener2 >> +{ >> + private final ComponentClassResolver resolver; >> + >> + private final ComponentSource componentSource; >> + >> + private final ComponentModelSource modelSource; >> + >> + public LinkDecorationListener(ComponentClassResolver resolver, >> ComponentSource componentSource, >> + ComponentModelSource modelSource) >> + { >> + this.resolver = resolver; >> + this.componentSource = componentSource; >> + this.modelSource = modelSource; >> + } >> + >> + public void createdComponentEventLink(Link link, >> ComponentEventRequestParameters parameters) >> + { >> + trigger(parameters.getActivePageName(), >> EventConstants.DECORATE_COMPONENT_EVENT_LINK, link, parameters); >> + } >> + >> + public void createdPageRenderLink(Link link, >> PageRenderRequestParameters parameters) >> + { >> + trigger(parameters.getLogicalPageName(), >> EventConstants.DECORATE_PAGE_RENDER_LINK, link, parameters); >> + } >> + >> + private void trigger(String pageName, String eventType, Link link, >> Object parameters) >> + { >> + String pageClassName = >> resolver.resolvePageNameToClassName(pageName); >> + >> + ComponentModel model = modelSource.getModel(pageClassName); >> + >> + if (model.handlesEvent(eventType)) >> + { >> + Component page = componentSource.getPage(pageName); >> + >> + page.getComponentResources().triggerEvent(eventType, new >> Object[] >> + { link, parameters }, null); >> + } >> + } >> +} >> >> Propchange: >> tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/LinkDecorationListener.java >> ------------------------------------------------------------------------------ >> svn:eol-style = native >> >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >
-- Howard M. Lewis Ship Creator of Apache Tapestry The source for Tapestry training, mentoring and support. Contact me to learn how I can get you up and productive in Tapestry fast! (971) 678-5210 http://howardlewisship.com --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
