You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2007/11/13 22:34:54 UTC
svn commit: r594648 [3/4] - in /tapestry/tapestry5/trunk: ./
tapestry-core/src/main/java/org/apache/tapestry/
tapestry-core/src/main/java/org/apache/tapestry/annotations/
tapestry-core/src/main/java/org/apache/tapestry/corelib/components/
tapestry-core...
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java?rev=594648&r1=594647&r2=594648&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java Tue Nov 13 13:34:47 2007
@@ -71,9 +71,8 @@
binder.bind(ClasspathAssetAliasManager.class, ClasspathAssetAliasManagerImpl.class);
binder.bind(PersistentLocale.class, PersistentLocaleImpl.class);
binder.bind(ApplicationStateManager.class, ApplicationStateManagerImpl.class);
- binder.bind(
- ApplicationStatePersistenceStrategySource.class,
- ApplicationStatePersistenceStrategySourceImpl.class);
+ binder.bind(ApplicationStatePersistenceStrategySource.class,
+ ApplicationStatePersistenceStrategySourceImpl.class);
binder.bind(BindingSource.class, BindingSourceImpl.class);
binder.bind(TranslatorSource.class, TranslatorSourceImpl.class);
binder.bind(PersistentFieldManager.class, PersistentFieldManagerImpl.class);
@@ -113,8 +112,7 @@
public static Alias build(Logger logger,
- @Inject
- @Symbol(InternalConstants.TAPESTRY_ALIAS_MODE_SYMBOL)
+ @Inject @Symbol(InternalConstants.TAPESTRY_ALIAS_MODE_SYMBOL)
String mode,
@InjectService("AliasOverrides")
@@ -145,11 +143,9 @@
* <dd> the <em>DefaultDataTypeAnalyzer</em> service
* </dl>
*/
- public static void contributeAlias(Configuration<AliasContribution> configuration,
- ObjectLocator locator,
+ public static void contributeAlias(Configuration<AliasContribution> configuration, ObjectLocator locator,
- @ComponentLayer
- ClassFactory componentClassFactory,
+ @ComponentLayer ClassFactory componentClassFactory,
@InjectService("DefaultDataTypeAnalyzer")
DataTypeAnalyzer dataTypeAnalyzer)
@@ -180,8 +176,7 @@
* A companion service to {@linkplain #build(Log, AliasManager, Collection) the Alias service}
* whose configuration contribution define spot overrides to specific services.
*/
- public static AliasManager buildAliasOverrides(Logger logger,
- Collection<AliasContribution> configuration)
+ public static AliasManager buildAliasOverrides(Logger logger, Collection<AliasContribution> configuration)
{
return new AliasManagerImpl(logger, configuration);
}
@@ -190,17 +185,16 @@
* Contributes the factory for serveral built-in binding prefixes ("asset", "literal", prop",
* "block", "component" "message", "validate", "translate").
*/
- public static void contributeBindingSource(
- MappedConfiguration<String, BindingFactory> configuration,
+ public static void contributeBindingSource(MappedConfiguration<String, BindingFactory> configuration,
- AssetSource assetSource,
+ AssetSource assetSource,
- @InjectService("PropBindingFactory")
- BindingFactory propBindingFactory,
+ @InjectService("PropBindingFactory")
+ BindingFactory propBindingFactory,
- FieldValidatorSource fieldValidatorSource,
+ FieldValidatorSource fieldValidatorSource,
- TranslatorSource translatorSource)
+ TranslatorSource translatorSource)
{
configuration.add(TapestryConstants.LITERAL_BINDING_PREFIX, new LiteralBindingFactory());
configuration.add(TapestryConstants.PROP_BINDING_PREFIX, propBindingFactory);
@@ -212,15 +206,14 @@
configuration.add("asset", new AssetBindingFactory(assetSource));
}
- public static void contributeClasspathAssetAliasManager(
- MappedConfiguration<String, String> configuration,
+ public static void contributeClasspathAssetAliasManager(MappedConfiguration<String, String> configuration,
- // @Inject not needed, because this isn't a service builder method
- @Symbol("tapestry.scriptaculous.path")
- String scriptaculousPath,
+ // @Inject not needed, because this isn't a service builder method
+ @Symbol("tapestry.scriptaculous.path")
+ String scriptaculousPath,
- @Symbol("tapestry.jscalendar.path")
- String jscalendarPath)
+ @Symbol("tapestry.jscalendar.path")
+ String jscalendarPath)
{
configuration.add("tapestry", "org/apache/tapestry");
@@ -312,50 +305,22 @@
add(configuration, TransformConstants.SETUP_RENDER_SIGNATURE, SetupRender.class, false);
add(configuration, TransformConstants.BEGIN_RENDER_SIGNATURE, BeginRender.class, false);
- add(
- configuration,
- TransformConstants.BEFORE_RENDER_TEMPLATE_SIGNATURE,
- BeforeRenderTemplate.class,
- false);
- add(
- configuration,
- TransformConstants.BEFORE_RENDER_BODY_SIGNATURE,
- BeforeRenderBody.class,
- false);
+ add(configuration, TransformConstants.BEFORE_RENDER_TEMPLATE_SIGNATURE, BeforeRenderTemplate.class, false);
+ add(configuration, TransformConstants.BEFORE_RENDER_BODY_SIGNATURE, BeforeRenderBody.class, false);
// These phases operate in reverse order.
- add(
- configuration,
- TransformConstants.AFTER_RENDER_BODY_SIGNATURE,
- AfterRenderBody.class,
- true);
- add(
- configuration,
- TransformConstants.AFTER_RENDER_TEMPLATE_SIGNATURE,
- AfterRenderTemplate.class,
- true);
+ add(configuration, TransformConstants.AFTER_RENDER_BODY_SIGNATURE, AfterRenderBody.class, true);
+ add(configuration, TransformConstants.AFTER_RENDER_TEMPLATE_SIGNATURE, AfterRenderTemplate.class, true);
add(configuration, TransformConstants.AFTER_RENDER_SIGNATURE, AfterRender.class, true);
add(configuration, TransformConstants.CLEANUP_RENDER_SIGNATURE, CleanupRender.class, true);
// Ideally, these should be ordered pretty late in the process to make sure there are no
// side effects with other workers that do work inside the page lifecycle methods.
- add(
- configuration,
- PageLoaded.class,
- TransformConstants.CONTAINING_PAGE_DID_LOAD_SIGNATURE,
- "pageLoaded");
- add(
- configuration,
- PageAttached.class,
- TransformConstants.CONTAINING_PAGE_DID_ATTACH_SIGNATURE,
- "pageAttached");
- add(
- configuration,
- PageDetached.class,
- TransformConstants.CONTAINING_PAGE_DID_DETACH_SIGNATURE,
- "pageDetached");
+ add(configuration, PageLoaded.class, TransformConstants.CONTAINING_PAGE_DID_LOAD_SIGNATURE, "pageLoaded");
+ add(configuration, PageAttached.class, TransformConstants.CONTAINING_PAGE_DID_ATTACH_SIGNATURE, "pageAttached");
+ add(configuration, PageDetached.class, TransformConstants.CONTAINING_PAGE_DID_DETACH_SIGNATURE, "pageDetached");
configuration.add("Retain", new RetainWorker());
configuration.add("Persist", new PersistWorker());
@@ -370,10 +335,9 @@
* Adds the {@link #buildDefaultDataTypeAnalyzer(Map) DefaultDatatTypeAnalyzer} to the
* configuration, ordered explicitly last.
*/
- public static void contributeDataTypeAnalyzer(
- OrderedConfiguration<DataTypeAnalyzer> configuration,
- @InjectService("DefaultDataTypeAnalyzer")
- DataTypeAnalyzer defaultDataTypeAnalyzer)
+ public static void contributeDataTypeAnalyzer(OrderedConfiguration<DataTypeAnalyzer> configuration,
+ @InjectService("DefaultDataTypeAnalyzer")
+ DataTypeAnalyzer defaultDataTypeAnalyzer)
{
configuration.add("Default", defaultDataTypeAnalyzer, "after:*");
}
@@ -388,8 +352,7 @@
* <li>Date --> date
* </ul>
*/
- public static void contributeDefaultDataTypeAnalyzer(
- MappedConfiguration<Class, String> configuration)
+ public static void contributeDefaultDataTypeAnalyzer(MappedConfiguration<Class, String> configuration)
{
// This is a special case contributed to avoid exceptions when a property type can't be
// matched. DefaultDataTypeAnalyzer converts the empty string to null.
@@ -418,17 +381,16 @@
addDisplayBlock(configuration, "date", "date");
}
- private static void addEditBlock(Configuration<BeanBlockContribution> configuration,
- String dataType, String blockId)
+ private static void addEditBlock(Configuration<BeanBlockContribution> configuration, String dataType,
+ String blockId)
{
configuration.add(new BeanBlockContribution(dataType, "PropertyEditBlocks", blockId, true));
}
- private static void addDisplayBlock(Configuration<BeanBlockContribution> configuration,
- String dataType, String blockId)
+ private static void addDisplayBlock(Configuration<BeanBlockContribution> configuration, String dataType,
+ String blockId)
{
- configuration.add(new BeanBlockContribution(dataType, "PropertyDisplayBlocks", blockId,
- false));
+ configuration.add(new BeanBlockContribution(dataType, "PropertyDisplayBlocks", blockId, false));
}
/**
@@ -442,8 +404,7 @@
* <li>regexp</li>
* </ul>
*/
- public static void contributeFieldValidatorSource(
- MappedConfiguration<String, Validator> configuration)
+ public static void contributeFieldValidatorSource(MappedConfiguration<String, Validator> configuration)
{
configuration.add("required", new Required());
configuration.add("minlength", new MinLength());
@@ -466,16 +427,15 @@
* field type against Tapestry IoC service</li>
* </ul>
*/
- public static void contributeInjectionProvider(
- OrderedConfiguration<InjectionProvider> configuration,
+ public static void contributeInjectionProvider(OrderedConfiguration<InjectionProvider> configuration,
- MasterObjectProvider masterObjectProvider,
+ MasterObjectProvider masterObjectProvider,
- ObjectLocator locator,
+ ObjectLocator locator,
- SymbolSource symbolSource,
+ SymbolSource symbolSource,
- AssetSource assetSource)
+ AssetSource assetSource)
{
configuration.add("Default", new DefaultInjectionProvider(masterObjectProvider, locator));
@@ -484,15 +444,9 @@
// This comes after default, to deal with conflicts between injecting a String as the
// component id, and injecting a string with @Symbol or @Value.
- configuration.add(
- "CommonResources",
- new CommonResourcesInjectionProvider(),
- "after:Default");
-
- configuration.add(
- "Asset",
- new AssetInjectionProvider(symbolSource, assetSource),
- "before:Default");
+ configuration.add("CommonResources", new CommonResourcesInjectionProvider(), "after:Default");
+
+ configuration.add("Asset", new AssetInjectionProvider(symbolSource, assetSource), "before:Default");
configuration.add("Block", new BlockInjectionProvider(), "before:Default");
@@ -510,14 +464,13 @@
* <li>Service: Injects based on the {@link Service} annotation, if present</li>
* </ul>
*/
- public static void contributeMasterObjectProvider(
- OrderedConfiguration<ObjectProvider> configuration,
+ public static void contributeMasterObjectProvider(OrderedConfiguration<ObjectProvider> configuration,
- @InjectService("Alias")
- final Alias alias,
+ @InjectService("Alias")
+ final Alias alias,
- @InjectService("AssetObjectProvider")
- ObjectProvider assetObjectProvider)
+ @InjectService("AssetObjectProvider")
+ ObjectProvider assetObjectProvider)
{
// There's a nasty web of dependencies related to Alias; this wrapper class lets us
// defer instantiating the Alias service implementation just long enough to defuse those
@@ -525,8 +478,7 @@
ObjectProvider wrapper = new ObjectProvider()
{
- public <T> T provide(Class<T> objectType, AnnotationProvider annotationProvider,
- ObjectLocator locator)
+ public <T> T provide(Class<T> objectType, AnnotationProvider annotationProvider, ObjectLocator locator)
{
return alias.getObjectProvider().provide(objectType, annotationProvider, locator);
}
@@ -544,8 +496,8 @@
* terminates the pipeline by returning false. Generally, most filters should be ordered after
* this filter.
*/
- public static void contributeRequestHandler(OrderedConfiguration<RequestFilter> configuration,
- Context context, final RequestExceptionHandler exceptionHandler)
+ public static void contributeRequestHandler(OrderedConfiguration<RequestFilter> configuration, Context context,
+ final RequestExceptionHandler exceptionHandler)
{
RequestFilter staticFilesFilter = new StaticFilesFilter(context);
@@ -553,8 +505,7 @@
RequestFilter errorFilter = new RequestFilter()
{
- public boolean service(Request request, Response response, RequestHandler handler)
- throws IOException
+ public boolean service(Request request, Response response, RequestHandler handler) throws IOException
{
try
{
@@ -589,8 +540,7 @@
* <li>Double</li>
* </li>
*/
- public static void contributeTranslatorDefaultSource(
- MappedConfiguration<Class, Translator> configuration)
+ public static void contributeTranslatorDefaultSource(MappedConfiguration<Class, Translator> configuration)
{
configuration.add(Integer.class, new IntegerTranslator());
configuration.add(String.class, new StringTranslator());
@@ -607,8 +557,7 @@
* <li>double</li>
* </ul>
*/
- public static void contributeTranslatorSource(
- MappedConfiguration<String, Translator> configuration)
+ public static void contributeTranslatorSource(MappedConfiguration<String, Translator> configuration)
{
// Fortunately, the translators are tiny, so we don't have to worry about the slight
// duplication between this and TranslatorDefaultSource, though it is a pain to keep the two
@@ -670,11 +619,8 @@
}
});
- add(
- configuration,
- String.class,
- GridPagerPosition.class,
- new StringToEnumCoercion<GridPagerPosition>(GridPagerPosition.class));
+ add(configuration, String.class, GridPagerPosition.class,
+ new StringToEnumCoercion<GridPagerPosition>(GridPagerPosition.class));
add(configuration, List.class, SelectModel.class, new Coercion<List, SelectModel>()
{
@@ -693,18 +639,15 @@
}
});
- add(
- configuration,
- ComponentResourcesAware.class,
- ComponentResources.class,
- new Coercion<ComponentResourcesAware, ComponentResources>()
- {
+ add(configuration, ComponentResourcesAware.class, ComponentResources.class,
+ new Coercion<ComponentResourcesAware, ComponentResources>()
+ {
- public ComponentResources coerce(ComponentResourcesAware input)
- {
- return input.getComponentResources();
- }
- });
+ public ComponentResources coerce(ComponentResourcesAware input)
+ {
+ return input.getComponentResources();
+ }
+ });
}
/**
@@ -721,8 +664,8 @@
configuration.add("ValidateAnnotation", new ValidateAnnotationConstraintGenerator());
}
- private static <S, T> void add(Configuration<CoercionTuple> configuration, Class<S> sourceType,
- Class<T> targetType, Coercion<S, T> coercion)
+ private static <S, T> void add(Configuration<CoercionTuple> configuration, Class<S> sourceType, Class<T> targetType,
+ Coercion<S, T> coercion)
{
CoercionTuple<S, T> tuple = new CoercionTuple<S, T>(sourceType, targetType, coercion);
@@ -749,8 +692,7 @@
String name = TapestryInternalUtils.lastTerm(annotationClass.getName());
- configuration.add(name, new ComponentLifecycleMethodWorker(signature, annotationClass,
- reverse));
+ configuration.add(name, new ComponentLifecycleMethodWorker(signature, annotationClass, reverse));
}
private final PipelineBuilder _pipelineBuilder;
@@ -809,8 +751,7 @@
PropertyAccess propertyAccess,
- @ComponentLayer
- ClassFactory componentClassFactory,
+ @ComponentLayer ClassFactory componentClassFactory,
UpdateListenerHub updateListenerHub, ThreadCleanupHub threadCleanupHub,
@@ -861,11 +802,9 @@
* paths to message bundles (resource paths within the classpath); the default contribution is
* "org/apache/tapestry/internal/ValidationMessages".
*/
- public ValidationMessagesSource build(Collection<String> configuration,
- UpdateListenerHub updateListenerHub,
+ public ValidationMessagesSource build(Collection<String> configuration, UpdateListenerHub updateListenerHub,
- @ClasspathProvider
- AssetFactory classpathAssetFactory)
+ @ClasspathProvider AssetFactory classpathAssetFactory)
{
ValidationMessagesSourceImpl service = new ValidationMessagesSourceImpl(configuration,
classpathAssetFactory.getRootResource());
@@ -885,14 +824,22 @@
}
/**
- * Builds a proxy to the current PageRenderSupport inside this thread's {@link Environment}.
+ * Builds a proxy to the current {@link org.apache.tapestry.PageRenderSupport} inside this thread's {@link Environment}.
*/
- public PageRenderSupport build(EnvironmentalShadowBuilder builder)
+ public PageRenderSupport buildPageRenderSupport(EnvironmentalShadowBuilder builder)
{
return builder.build(PageRenderSupport.class);
}
/**
+ * Builds a proxy to the current {@link org.apache.tapestry.services.FormSupport} inside this thread's {@link org.apache.tapestry.services.Environment}.
+ */
+ public FormSupport buildFormSupport(EnvironmentalShadowBuilder builder)
+ {
+ return builder.build(FormSupport.class);
+ }
+
+ /**
* Allows the exact steps in the component class transformation process to be defined.
*/
public ComponentClassTransformWorker build(List<ComponentClassTransformWorker> configuration)
@@ -928,8 +875,7 @@
{
Iterator<PageRenderCommand> i = InternalUtils.reverseIterator(configuration);
- while (i.hasNext())
- i.next().cleanup(_environment);
+ while (i.hasNext()) i.next().cleanup(_environment);
_environment.clear();
}
@@ -950,8 +896,7 @@
/**
* Initializes the application.
*/
- public ApplicationInitializer build(Logger logger,
- List<ApplicationInitializerFilter> configuration)
+ public ApplicationInitializer build(Logger logger, List<ApplicationInitializerFilter> configuration)
{
ApplicationInitializer terminator = new ApplicationInitializer()
{
@@ -961,24 +906,18 @@
}
};
- return _pipelineBuilder.build(
- logger,
- ApplicationInitializer.class,
- ApplicationInitializerFilter.class,
- configuration,
- terminator);
+ return _pipelineBuilder.build(logger, ApplicationInitializer.class, ApplicationInitializerFilter.class,
+ configuration, terminator);
}
- public HttpServletRequestHandler build(Logger logger,
- List<HttpServletRequestFilter> configuration,
+ public HttpServletRequestHandler build(Logger logger, List<HttpServletRequestFilter> configuration,
@InjectService("RequestHandler")
final RequestHandler handler)
{
HttpServletRequestHandler terminator = new HttpServletRequestHandler()
{
- public boolean service(HttpServletRequest request, HttpServletResponse response)
- throws IOException
+ public boolean service(HttpServletRequest request, HttpServletResponse response) throws IOException
{
_requestGlobals.store(request, response);
@@ -986,17 +925,12 @@
}
};
- return _pipelineBuilder.build(
- logger,
- HttpServletRequestHandler.class,
- HttpServletRequestFilter.class,
- configuration,
- terminator);
+ return _pipelineBuilder.build(logger, HttpServletRequestHandler.class, HttpServletRequestFilter.class,
+ configuration, terminator);
}
- public RequestHandler build(Logger logger, List<RequestFilter> configuration,
- @InjectService("MasterDispatcher")
- final Dispatcher masterDispatcher)
+ public RequestHandler build(Logger logger, List<RequestFilter> configuration, @InjectService("MasterDispatcher")
+ final Dispatcher masterDispatcher)
{
RequestHandler terminator = new RequestHandler()
{
@@ -1008,16 +942,10 @@
}
};
- return _pipelineBuilder.build(
- logger,
- RequestHandler.class,
- RequestFilter.class,
- configuration,
- terminator);
+ return _pipelineBuilder.build(logger, RequestHandler.class, RequestFilter.class, configuration, terminator);
}
- public ServletApplicationInitializer build(Logger logger,
- List<ServletApplicationInitializerFilter> configuration,
+ public ServletApplicationInitializer build(Logger logger, List<ServletApplicationInitializerFilter> configuration,
@InjectService("ApplicationInitializer")
final ApplicationInitializer initializer)
{
@@ -1033,17 +961,12 @@
}
};
- return _pipelineBuilder.build(
- logger,
- ServletApplicationInitializer.class,
- ServletApplicationInitializerFilter.class,
- configuration,
- terminator);
+ return _pipelineBuilder.build(logger, ServletApplicationInitializer.class,
+ ServletApplicationInitializerFilter.class, configuration, terminator);
}
@Marker(Primary.class)
- public ComponentEventResultProcessor build(
- Map<Class, ComponentEventResultProcessor> configuration)
+ public ComponentEventResultProcessor build(Map<Class, ComponentEventResultProcessor> configuration)
{
// A slight hack!
@@ -1051,8 +974,7 @@
.keySet()));
StrategyRegistry<ComponentEventResultProcessor> registry = StrategyRegistry.newInstance(
- ComponentEventResultProcessor.class,
- configuration);
+ ComponentEventResultProcessor.class, configuration);
return _strategyBuilder.build(registry);
}
@@ -1081,23 +1003,18 @@
return service;
}
- public ObjectRenderer build(StrategyBuilder strategyBuilder,
- Map<Class, ObjectRenderer> configuration)
+ public ObjectRenderer build(StrategyBuilder strategyBuilder, Map<Class, ObjectRenderer> configuration)
{
- StrategyRegistry<ObjectRenderer> registry = StrategyRegistry.newInstance(
- ObjectRenderer.class,
- configuration);
+ StrategyRegistry<ObjectRenderer> registry = StrategyRegistry.newInstance(ObjectRenderer.class, configuration);
return _strategyBuilder.build(registry);
}
public static ComponentMessagesSource build(UpdateListenerHub updateListenerHub,
- @ContextProvider
- AssetFactory contextAssetFactory,
+ @ContextProvider AssetFactory contextAssetFactory,
- @Inject
- @Value("WEB-INF/${tapestry.app-name}.properties")
+ @Inject @Value("WEB-INF/${tapestry.app-name}.properties")
String appCatalog)
{
ComponentMessagesSourceImpl service = new ComponentMessagesSourceImpl(contextAssetFactory
@@ -1119,10 +1036,7 @@
@Marker(ComponentLayer.class)
public ClassFactory buildComponentClassFactory()
{
- return _shadowBuilder.build(
- _componentInstantiatorSource,
- "classFactory",
- ClassFactory.class);
+ return _shadowBuilder.build(_componentInstantiatorSource, "classFactory", ClassFactory.class);
}
public ComponentEventResultProcessor buildComponentInstanceResultProcessor(Logger logger)
@@ -1141,8 +1055,7 @@
public PropertyConduitSource buildPropertyConduitSource()
{
- PropertyConduitSourceImpl service = new PropertyConduitSourceImpl(_propertyAccess,
- _componentClassFactory);
+ PropertyConduitSourceImpl service = new PropertyConduitSourceImpl(_propertyAccess, _componentClassFactory);
_componentInstantiatorSource.addInvalidationListener(service);
@@ -1179,11 +1092,9 @@
}
public void contributeAssetSource(MappedConfiguration<String, AssetFactory> configuration,
- @ContextProvider
- AssetFactory contextAssetFactory,
+ @ContextProvider AssetFactory contextAssetFactory,
- @ClasspathProvider
- AssetFactory classpathAssetFactory)
+ @ClasspathProvider AssetFactory classpathAssetFactory)
{
configuration.add("context", contextAssetFactory);
configuration.add("classpath", classpathAssetFactory);
@@ -1213,17 +1124,14 @@
MappedConfiguration<Class, ComponentEventResultProcessor> configuration)
{
- configuration.add(
- ActionResponseGenerator.class,
- new ComponentEventResultProcessor<ActionResponseGenerator>()
- {
- public ActionResponseGenerator processComponentEvent(
- ActionResponseGenerator value, Component component,
- String methodDescripion)
- {
- return value;
- }
- });
+ configuration.add(ActionResponseGenerator.class, new ComponentEventResultProcessor<ActionResponseGenerator>()
+ {
+ public ActionResponseGenerator processComponentEvent(ActionResponseGenerator value, Component component,
+ String methodDescripion)
+ {
+ return value;
+ }
+ });
configuration.add(Link.class, new ComponentEventResultProcessor<Link>()
{
@@ -1237,8 +1145,8 @@
configuration.add(String.class, new StringResultProcessor(_requestPageCache, _linkFactory));
- configuration.add(Class.class, new ClassResultProcessor(componentClassResolver,
- _requestPageCache, _linkFactory));
+ configuration.add(Class.class,
+ new ClassResultProcessor(componentClassResolver, _requestPageCache, _linkFactory));
configuration.add(Component.class, componentInstanceProcessor);
@@ -1264,22 +1172,19 @@
{
// Looks for the root path and renders the start page
- configuration.add("RootPath", new RootPathDispatcher(componentClassResolver,
- pageRenderRequestHandler, startPageName), "before:Asset");
+ configuration.add("RootPath",
+ new RootPathDispatcher(componentClassResolver, pageRenderRequestHandler, startPageName),
+ "before:Asset");
// This goes first because an asset to be streamed may have an file extension, such as
// ".html", that will confuse the later dispatchers.
- configuration.add(
- "Asset",
- new AssetDispatcher(streamer, aliasManager, resourceCache),
- "before:PageRender");
+ configuration.add("Asset", new AssetDispatcher(streamer, aliasManager, resourceCache), "before:PageRender");
- configuration.add("PageRender", new PageRenderDispatcher(componentClassResolver,
- pageRenderRequestHandler));
+ configuration.add("PageRender", new PageRenderDispatcher(componentClassResolver, pageRenderRequestHandler));
- configuration.add("ComponentAction", new ComponentActionDispatcher(
- componentActionRequestHandler), "after:PageRender");
+ configuration.add("ComponentAction", new ComponentActionDispatcher(componentActionRequestHandler),
+ "after:PageRender");
}
/**
@@ -1297,9 +1202,7 @@
*/
public void contributeMetaDataLocator(MappedConfiguration<String, String> configuration)
{
- configuration.add(
- PersistentFieldManagerImpl.META_KEY,
- PersistentFieldManagerImpl.DEFAULT_STRATEGY);
+ configuration.add(PersistentFieldManagerImpl.META_KEY, PersistentFieldManagerImpl.DEFAULT_STRATEGY);
configuration.add(TapestryConstants.RESPONSE_CONTENT_TYPE, "text/html");
configuration.add(TapestryConstants.RESPONSE_ENCODING, "UTF-8");
@@ -1341,22 +1244,21 @@
configuration.add(ClassTransformation.class, preformatted);
}
- public void contributePageRenderInitializer(
- OrderedConfiguration<PageRenderCommand> configuration,
+ public void contributePageRenderInitializer(OrderedConfiguration<PageRenderCommand> configuration,
- ThreadLocale threadLocale,
+ ThreadLocale threadLocale,
- @Path("org/apache/tapestry/default.css")
- final Asset stylesheetAsset,
+ @Path("org/apache/tapestry/default.css")
+ final Asset stylesheetAsset,
- @Path("org/apache/tapestry/field-error-marker.png")
- Asset fieldErrorIcon,
+ @Path("org/apache/tapestry/field-error-marker.png")
+ Asset fieldErrorIcon,
- ValidationMessagesSource validationMessagesSource,
+ ValidationMessagesSource validationMessagesSource,
- final SymbolSource symbolSource,
+ final SymbolSource symbolSource,
- final AssetSource assetSource)
+ final AssetSource assetSource)
{
configuration.add("PageRenderSupport", new PageRenderCommand()
{
@@ -1377,9 +1279,7 @@
environment.push(DocumentHeadBuilder.class, builder);
- PageRenderSupportImpl support = new PageRenderSupportImpl(builder,
- symbolSource,
- assetSource,
+ PageRenderSupportImpl support = new PageRenderSupportImpl(builder, symbolSource, assetSource,
// Core scripts added to any page that uses scripting
@@ -1410,8 +1310,8 @@
}
});
- configuration.add("DefaultValidationDelegate", new DefaultValidationDelegateCommand(
- threadLocale, validationMessagesSource, fieldErrorIcon));
+ configuration.add("DefaultValidationDelegate",
+ new DefaultValidationDelegateCommand(threadLocale, validationMessagesSource, fieldErrorIcon));
}
/**
@@ -1425,13 +1325,12 @@
* <dd>Values are encoded into URLs (or hidden form fields)
* </dl>
*/
- public void contributePersistentFieldManager(
- MappedConfiguration<String, PersistentFieldStrategy> configuration,
+ public void contributePersistentFieldManager(MappedConfiguration<String, PersistentFieldStrategy> configuration,
- Request request,
+ Request request,
- @InjectService("ClientPersistentFieldStrategy")
- PersistentFieldStrategy clientStrategy)
+ @InjectService("ClientPersistentFieldStrategy")
+ PersistentFieldStrategy clientStrategy)
{
configuration.add("session", new SessionPersistentFieldStrategy(request));
configuration.add("flash", new FlashPersistentFieldStrategy(request));
@@ -1462,34 +1361,24 @@
* @param configuration
*/
@SuppressWarnings("unchecked")
- public static void contributeValueEncoderSource(
- MappedConfiguration<Class, ValueEncoderFactory> configuration)
+ public static void contributeValueEncoderSource(MappedConfiguration<Class, ValueEncoderFactory> configuration)
{
configuration.add(String.class, new GenericValueEncoderFactory(new StringValueEncoder()));
configuration.add(Enum.class, new EnumValueEncoderFactory());
}
- public PageRenderRequestHandler buildPageRenderRequestHandler(
- List<PageRenderRequestFilter> configuration, Logger logger, ServiceResources resources)
+ public PageRenderRequestHandler buildPageRenderRequestHandler(List<PageRenderRequestFilter> configuration,
+ Logger logger, ServiceResources resources)
{
- return _pipelineBuilder.build(
- logger,
- PageRenderRequestHandler.class,
- PageRenderRequestFilter.class,
- configuration,
- resources.autobuild(PageRenderRequestHandlerImpl.class));
+ return _pipelineBuilder.build(logger, PageRenderRequestHandler.class, PageRenderRequestFilter.class,
+ configuration, resources.autobuild(PageRenderRequestHandlerImpl.class));
}
public ComponentActionRequestHandler buildComponentActionRequestHandler(
- List<ComponentActionRequestFilter> configuration, Logger logger,
- ServiceResources resources)
+ List<ComponentActionRequestFilter> configuration, Logger logger, ServiceResources resources)
{
- return _pipelineBuilder.build(
- logger,
- ComponentActionRequestHandler.class,
- ComponentActionRequestFilter.class,
- configuration,
- resources.autobuild(ComponentActionRequestHandlerImpl.class));
+ return _pipelineBuilder.build(logger, ComponentActionRequestHandler.class, ComponentActionRequestFilter.class,
+ configuration, resources.autobuild(ComponentActionRequestHandlerImpl.class));
}
/**
@@ -1566,17 +1455,14 @@
configuration.add("tapestry.jscalendar", "classpath:${tapestry.jscalendar.path}");
}
- public PageTemplateLocator build(@ContextProvider
- AssetFactory contextAssetFactory,
+ public PageTemplateLocator build(@ContextProvider AssetFactory contextAssetFactory,
ComponentClassResolver componentClassResolver)
{
- return new PageTemplateLocatorImpl(contextAssetFactory.getRootResource(),
- componentClassResolver);
+ return new PageTemplateLocatorImpl(contextAssetFactory.getRootResource(), componentClassResolver);
}
- public ComponentInstantiatorSource build(@Builtin
- ClassFactory classFactory,
+ public ComponentInstantiatorSource build(@Builtin ClassFactory classFactory,
ComponentClassTransformer transformer,
@@ -1600,8 +1486,8 @@
return transformer;
}
- public PagePool build(Logger logger, PageLoader pageLoader,
- ComponentMessagesSource componentMessagesSource, ComponentClassResolver resolver)
+ public PagePool build(Logger logger, PageLoader pageLoader, ComponentMessagesSource componentMessagesSource,
+ ComponentClassResolver resolver)
{
PagePoolImpl service = new PagePoolImpl(logger, pageLoader, _threadLocale, resolver);
@@ -1735,10 +1621,9 @@
* Adds a filter that sets the application package (for class loading purposes). The filter is
* ordered before:*.*".
*/
- public void contributeApplicationInitializer(
- OrderedConfiguration<ApplicationInitializerFilter> configuration,
- final ApplicationGlobals applicationGlobals, final PropertyAccess propertyAccess,
- final TypeCoercer typeCoercer)
+ public void contributeApplicationInitializer(OrderedConfiguration<ApplicationInitializerFilter> configuration,
+ final ApplicationGlobals applicationGlobals,
+ final PropertyAccess propertyAccess, final TypeCoercer typeCoercer)
{
final InvalidationListener listener = new InvalidationListener()
{
@@ -1777,13 +1662,12 @@
_keywords.put("null", null);
}
- public Binding newBinding(String description, ComponentResources container,
- ComponentResources component, String expression, Location location)
+ public Binding newBinding(String description, ComponentResources container, ComponentResources component,
+ String expression, Location location)
{
String key = expression.trim();
- if (_keywords.containsKey(key))
- return new LiteralBinding(description, _keywords.get(key), location);
+ if (_keywords.containsKey(key)) return new LiteralBinding(description, _keywords.get(key), location);
return null;
}
@@ -1792,8 +1676,8 @@
BindingFactory thisFactory = new BindingFactory()
{
- public Binding newBinding(String description, ComponentResources container,
- ComponentResources component, String expression, Location location)
+ public Binding newBinding(String description, ComponentResources container, ComponentResources component,
+ String expression, Location location)
{
if ("this".equalsIgnoreCase(expression.trim()))
return new LiteralBinding(description, container.getComponent(), location);
@@ -1806,8 +1690,8 @@
{
private final Pattern _pattern = Pattern.compile("^\\s*(-?\\d+)\\s*$");
- public Binding newBinding(String description, ComponentResources container,
- ComponentResources component, String expression, Location location)
+ public Binding newBinding(String description, ComponentResources container, ComponentResources component,
+ String expression, Location location)
{
Matcher matcher = _pattern.matcher(expression);
@@ -1827,8 +1711,8 @@
private final Pattern _pattern = Pattern
.compile("^\\s*(-?\\d+)\\s*\\.\\.\\s*(-?\\d+)\\s*$");
- public Binding newBinding(String description, ComponentResources container,
- ComponentResources component, String expression, Location location)
+ public Binding newBinding(String description, ComponentResources container, ComponentResources component,
+ String expression, Location location)
{
Matcher matcher = _pattern.matcher(expression);
@@ -1852,8 +1736,8 @@
private final Pattern _pattern = Pattern
.compile("^\\s*(\\-?((\\d+\\.)|(\\d*\\.\\d+)))\\s*$");
- public Binding newBinding(String description, ComponentResources container,
- ComponentResources component, String expression, Location location)
+ public Binding newBinding(String description, ComponentResources container, ComponentResources component,
+ String expression, Location location)
{
Matcher matcher = _pattern.matcher(expression);
@@ -1874,8 +1758,8 @@
private final Pattern _pattern = Pattern.compile("^\\s*'(.*)'\\s*$");
- public Binding newBinding(String description, ComponentResources container,
- ComponentResources component, String expression, Location location)
+ public Binding newBinding(String description, ComponentResources container, ComponentResources component,
+ String expression, Location location)
{
Matcher matcher = _pattern.matcher(expression);
@@ -1915,8 +1799,8 @@
LocalizationSetter localizationSetter)
{
- configuration.add("CheckForUpdates", new CheckForUpdatesFilter(_updateListenerHub,
- checkInterval, updateTimeout), "before:*");
+ configuration.add("CheckForUpdates",
+ new CheckForUpdatesFilter(_updateListenerHub, checkInterval, updateTimeout), "before:*");
configuration.add("Localization", new LocalizationFilter(localizationSetter));
}
@@ -1938,18 +1822,13 @@
{
ComponentActionRequestFilter filter = new ComponentActionRequestFilter()
{
- public ActionResponseGenerator handle(String logicalPageName, String nestedComponentId,
- String eventType, String[] context, String[] activationContext,
+ public ActionResponseGenerator handle(String logicalPageName, String nestedComponentId, String eventType,
+ String[] context, String[] activationContext,
ComponentActionRequestHandler handler)
{
encodingInitializer.initializeRequestEncoding(logicalPageName);
- return handler.handle(
- logicalPageName,
- nestedComponentId,
- eventType,
- context,
- activationContext);
+ return handler.handle(logicalPageName, nestedComponentId, eventType, context, activationContext);
}
};
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TransformUtils.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TransformUtils.java?rev=594648&r1=594647&r2=594648&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TransformUtils.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TransformUtils.java Tue Nov 13 13:34:47 2007
@@ -74,11 +74,9 @@
{
}
- private static void add(Class primitiveType, Class wrapperType, String unwrapperMethodName,
- String defaultValue)
+ private static void add(Class primitiveType, Class wrapperType, String unwrapperMethodName, String defaultValue)
{
- PrimitiveTypeInfo info = new PrimitiveTypeInfo(wrapperType, unwrapperMethodName,
- defaultValue);
+ PrimitiveTypeInfo info = new PrimitiveTypeInfo(wrapperType, unwrapperMethodName, defaultValue);
_classToInfo.put(primitiveType, info);
_nameToInfo.put(primitiveType.getName(), info);
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/validator/Max.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/validator/Max.java?rev=594648&r1=594647&r2=594648&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/validator/Max.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/validator/Max.java Tue Nov 13 13:34:47 2007
@@ -14,9 +14,12 @@
package org.apache.tapestry.validator;
-import org.apache.tapestry.*;
-import static org.apache.tapestry.TapestryUtils.quote;
+import org.apache.tapestry.Field;
+import org.apache.tapestry.MarkupWriter;
+import org.apache.tapestry.ValidationException;
+import org.apache.tapestry.Validator;
import org.apache.tapestry.ioc.MessageFormatter;
+import org.apache.tapestry.services.FormSupport;
/**
* Enforces a maximum integer value.
@@ -55,15 +58,10 @@
return formatter.format(constraintValue, field.getLabel());
}
- public void render(Field field, Long constraintValue, MessageFormatter formatter,
- MarkupWriter writer, PageRenderSupport pageRenderSupport)
+ public void render(Field field, Long constraintValue, MessageFormatter formatter, MarkupWriter writer,
+ FormSupport formSupport)
{
- pageRenderSupport.addScript(
- "Tapestry.Field.max('%s', %d, %s);",
- field.getClientId(),
- constraintValue,
- quote(buildMessage(formatter, field, constraintValue)));
-
+ formSupport.addValidation(field, "max", buildMessage(formatter, field, constraintValue), constraintValue);
}
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/validator/MaxLength.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/validator/MaxLength.java?rev=594648&r1=594647&r2=594648&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/validator/MaxLength.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/validator/MaxLength.java Tue Nov 13 13:34:47 2007
@@ -14,9 +14,12 @@
package org.apache.tapestry.validator;
-import org.apache.tapestry.*;
-import static org.apache.tapestry.TapestryUtils.quote;
+import org.apache.tapestry.Field;
+import org.apache.tapestry.MarkupWriter;
+import org.apache.tapestry.ValidationException;
+import org.apache.tapestry.Validator;
import org.apache.tapestry.ioc.MessageFormatter;
+import org.apache.tapestry.services.FormSupport;
public final class MaxLength implements Validator<Integer, String>
{
@@ -40,8 +43,8 @@
return false;
}
- public void validate(Field field, Integer constraintValue, MessageFormatter formatter,
- String value) throws ValidationException
+ public void validate(Field field, Integer constraintValue, MessageFormatter formatter, String value)
+ throws ValidationException
{
if (value.length() > constraintValue)
throw new ValidationException(buildMessage(formatter, field, constraintValue));
@@ -52,16 +55,12 @@
return formatter.format(constraintValue, field.getLabel());
}
- public void render(Field field, Integer constraintValue, MessageFormatter formatter,
- MarkupWriter writer, PageRenderSupport pageRenderSupport)
+ public void render(Field field, Integer constraintValue, MessageFormatter formatter, MarkupWriter writer,
+ FormSupport formSupport)
{
// TODO: write a maxlength attribute into the element? But that's only for
// textfield, not for textarea.
- pageRenderSupport.addScript(
- "Tapestry.Field.maxlength('%s', %d, %s);",
- field.getClientId(),
- constraintValue,
- quote(buildMessage(formatter, field, constraintValue)));
+ formSupport.addValidation(field, "maxlength", buildMessage(formatter, field, constraintValue), constraintValue);
}
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/validator/Min.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/validator/Min.java?rev=594648&r1=594647&r2=594648&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/validator/Min.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/validator/Min.java Tue Nov 13 13:34:47 2007
@@ -14,9 +14,12 @@
package org.apache.tapestry.validator;
-import org.apache.tapestry.*;
-import static org.apache.tapestry.TapestryUtils.quote;
+import org.apache.tapestry.Field;
+import org.apache.tapestry.MarkupWriter;
+import org.apache.tapestry.ValidationException;
+import org.apache.tapestry.Validator;
import org.apache.tapestry.ioc.MessageFormatter;
+import org.apache.tapestry.services.FormSupport;
/* A vaidator that enforces that a number is greater than some minimum integer value. */
public class Min implements Validator<Long, Number>
@@ -53,13 +56,9 @@
return formatter.format(constraintValue, field.getLabel());
}
- public void render(Field field, Long constraintValue, MessageFormatter formatter,
- MarkupWriter writer, PageRenderSupport pageRenderSupport)
+ public void render(Field field, Long constraintValue, MessageFormatter formatter, MarkupWriter writer,
+ FormSupport formSupport)
{
- pageRenderSupport.addScript(
- "Tapestry.Field.min('%s', %s, %s);",
- field.getClientId(),
- constraintValue,
- quote(buildMessage(formatter, field, constraintValue)));
+ formSupport.addValidation(field, "min", buildMessage(formatter, field, constraintValue), constraintValue);
}
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/validator/MinLength.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/validator/MinLength.java?rev=594648&r1=594647&r2=594648&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/validator/MinLength.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/validator/MinLength.java Tue Nov 13 13:34:47 2007
@@ -14,9 +14,12 @@
package org.apache.tapestry.validator;
-import org.apache.tapestry.*;
-import static org.apache.tapestry.TapestryUtils.quote;
+import org.apache.tapestry.Field;
+import org.apache.tapestry.MarkupWriter;
+import org.apache.tapestry.ValidationException;
+import org.apache.tapestry.Validator;
import org.apache.tapestry.ioc.MessageFormatter;
+import org.apache.tapestry.services.FormSupport;
/**
* Validates that a string value has a minimum length.
@@ -28,8 +31,8 @@
return "minimum-string-length";
}
- public void validate(Field field, Integer constraintValue, MessageFormatter formatter,
- String value) throws ValidationException
+ public void validate(Field field, Integer constraintValue, MessageFormatter formatter, String value)
+ throws ValidationException
{
if (value.length() < constraintValue)
throw new ValidationException(buildMessage(formatter, field, constraintValue));
@@ -55,13 +58,9 @@
return String.class;
}
- public void render(Field field, Integer constraintValue, MessageFormatter formatter,
- MarkupWriter writer, PageRenderSupport pageRenderSupport)
+ public void render(Field field, Integer constraintValue, MessageFormatter formatter, MarkupWriter writer,
+ FormSupport formSupport)
{
- pageRenderSupport.addScript(
- "Tapestry.Field.minlength('%s', %d, %s);",
- field.getClientId(),
- constraintValue,
- quote(buildMessage(formatter, field, constraintValue)));
+ formSupport.addValidation(field, "minlength", buildMessage(formatter, field, constraintValue), constraintValue);
}
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/validator/Regexp.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/validator/Regexp.java?rev=594648&r1=594647&r2=594648&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/validator/Regexp.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/validator/Regexp.java Tue Nov 13 13:34:47 2007
@@ -14,9 +14,12 @@
package org.apache.tapestry.validator;
-import org.apache.tapestry.*;
-import static org.apache.tapestry.TapestryUtils.quote;
+import org.apache.tapestry.Field;
+import org.apache.tapestry.MarkupWriter;
+import org.apache.tapestry.ValidationException;
+import org.apache.tapestry.Validator;
import org.apache.tapestry.ioc.MessageFormatter;
+import org.apache.tapestry.services.FormSupport;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -48,24 +51,19 @@
return formatter.format(constraintValue.toString(), field.getLabel());
}
- public void render(Field field, Pattern constraintValue, MessageFormatter formatter,
- MarkupWriter writer, PageRenderSupport pageRenderSupport)
+ public void render(Field field, Pattern constraintValue, MessageFormatter formatter, MarkupWriter writer,
+ FormSupport formSupport)
{
- pageRenderSupport.addScript(
- "Tapestry.Field.regexp('%s', %s, %s);",
- field.getClientId(),
- quote(constraintValue.pattern()),
- quote(buildMessage(formatter, field, constraintValue)));
-
+ formSupport.addValidation(field, "regexp", buildMessage(formatter, field, constraintValue),
+ constraintValue.pattern());
}
- public void validate(Field field, Pattern constraintValue, MessageFormatter formatter,
- String value) throws ValidationException
+ public void validate(Field field, Pattern constraintValue, MessageFormatter formatter, String value)
+ throws ValidationException
{
Matcher matcher = constraintValue.matcher(value);
- if (!matcher.matches())
- throw new ValidationException(buildMessage(formatter, field, constraintValue));
+ if (!matcher.matches()) throw new ValidationException(buildMessage(formatter, field, constraintValue));
}
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/validator/Required.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/validator/Required.java?rev=594648&r1=594647&r2=594648&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/validator/Required.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/validator/Required.java Tue Nov 13 13:34:47 2007
@@ -14,9 +14,12 @@
package org.apache.tapestry.validator;
-import org.apache.tapestry.*;
-import static org.apache.tapestry.TapestryUtils.quote;
+import org.apache.tapestry.Field;
+import org.apache.tapestry.MarkupWriter;
+import org.apache.tapestry.ValidationException;
+import org.apache.tapestry.Validator;
import org.apache.tapestry.ioc.MessageFormatter;
+import org.apache.tapestry.services.FormSupport;
/**
* A validator that enforces that the value is not null and not the empty string. This validator is
@@ -32,8 +35,7 @@
public void validate(Field field, Void constraintValue, MessageFormatter formatter, Object value)
throws ValidationException
{
- if (value == null || value.toString().equals(""))
- throw new ValidationException(buildMessage(formatter, field));
+ if (value == null || value.toString().equals("")) throw new ValidationException(buildMessage(formatter, field));
}
private String buildMessage(MessageFormatter formatter, Field field)
@@ -56,13 +58,9 @@
return Object.class;
}
- public void render(Field field, Void constraintValue, MessageFormatter formatter,
- MarkupWriter writer, PageRenderSupport pageRenderSupport)
+ public void render(Field field, Void constraintValue, MessageFormatter formatter, MarkupWriter writer,
+ FormSupport formSupport)
{
- pageRenderSupport.addScript(
- "Tapestry.Field.required('%s', %s);",
- field.getClientId(),
- quote(buildMessage(formatter, field)));
-
+ formSupport.addValidation(field, "required", buildMessage(formatter, field), null);
}
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/tapestry.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/tapestry.js?rev=594648&r1=594647&r2=594648&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/tapestry.js (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/tapestry.js Tue Nov 13 13:34:47 2007
@@ -14,7 +14,7 @@
var Tapestry = {
- registerForm : function(form)
+ registerForm : function(form, clientValidations)
{
form = $(form);
@@ -96,12 +96,46 @@
new Insertion.Bottom(form.errorList, "<li>" + message + "</li>");
};
+
+ // And handle the validations
+
+ this.registerValidations(form, clientValidations);
+ },
+
+ registerValidations : function(form, clientValidations)
+ {
+ $H(clientValidations).each(function(pair)
+ {
+ var field = $(pair.key);
+ var specs = pair.value;
+
+ specs.each(function(spec)
+ {
+ // spec is a 2 or 3 element array.
+ // validator function name, message, optional constraint
+
+ var name = spec[0];
+ var message = spec[1];
+ var constraint = spec[2];
+
+ var vfunc = Tapestry.Validator[name];
+
+ if (vfunc == undefined)
+ {
+ var errorMessage = "Function Tapestry.Validator.#{name}() does not exist for field '#{fieldName}'.".interpolate({name:name, fieldName:pair.key});
+
+ window.alert(errorMessage);
+ }
+
+ vfunc.call(this, field, message, constraint);
+ });
+ });
},
-// Checks the element; if it has the "t-invisible" CSS class, then
-// the element is hidden,and the t-invisible CSS class is removed. This is necessary
-// for Prototype's visible() method, which can't determine visibility when it's defined via
-// CSS.
+ // Checks the element; if it has the "t-invisible" CSS class, then
+ // the element is hidden,and the t-invisible CSS class is removed. This is necessary
+ // for Prototype's visible() method, which can't determine visibility when it's defined via
+ // CSS.
hideInvisible : function(element)
{
@@ -118,12 +152,12 @@
FieldEventManager : Class.create(),
-// Adds a validator for a field. A FieldEventManager is added, if necessary.
-// The validator will be called only for non-blank values, unless acceptBlank is
-// true (in most cases, acceptBlank is flase). The validator is a function
-// that accepts the current field value as its first parameter, and a
-// Tapestry.FormEvent as its second. It can invoke recordError() on the event
-// if the input is not valid.
+ // Adds a validator for a field. A FieldEventManager is added, if necessary.
+ // The validator will be called only for non-blank values, unless acceptBlank is
+ // true (in most cases, acceptBlank is flase). The validator is a function
+ // that accepts the current field value as its first parameter, and a
+ // Tapestry.FormEvent as its second. It can invoke recordError() on the event
+ // if the input is not valid.
addValidator : function(field, acceptBlank, validator)
{
@@ -139,9 +173,9 @@
// New methods added to Element.
Tapestry.ElementAdditions = {
-// This is added to all Elements, but really only applys to form control elements. This method is invoked
-// when a validation error is associated with a field. This gives the field a chance to decorate itself, its label
-// and its icon.
+ // This is added to all Elements, but really only applys to form control elements. This method is invoked
+ // when a validation error is associated with a field. This gives the field a chance to decorate itself, its label
+ // and its icon.
decorateForValidationError : function (element, event, message)
{
$(element).fieldEventManager.addDecorations(event, message);
@@ -150,9 +184,10 @@
Element.addMethods(Tapestry.ElementAdditions);
-// Collection of field based functions related to validation.
+// Collection of field based functions related to validation. Each
+// function takes a field, a message and an optional constraint value.
-Tapestry.Field = {
+Tapestry.Validator = {
required : function(field, message)
{
Tapestry.addValidator(field, true, function(value, event)
@@ -162,7 +197,7 @@
});
},
- minlength : function(field, length, message)
+ minlength : function(field, message, length)
{
Tapestry.addValidator(field, false, function(value, event)
{
@@ -171,7 +206,7 @@
});
},
- maxlength : function(field, maxlength, message)
+ maxlength : function(field, message, maxlength)
{
Tapestry.addValidator(field, false, function(value, event)
{
@@ -180,7 +215,7 @@
});
},
- min : function(field, minValue, message)
+ min : function(field, message, minValue)
{
Tapestry.addValidator(field, false, function(value, event)
{
@@ -189,7 +224,7 @@
});
},
- max : function(field, maxValue, message)
+ max : function(field, message, maxValue)
{
Tapestry.addValidator(field, false, function(value, event)
{
@@ -198,13 +233,12 @@
});
},
- regexp : function(field, pattern, message)
+ regexp : function(field, message, pattern)
{
var regexp = new RegExp(pattern);
Tapestry.addValidator(field, false, function(value, event)
{
-
if (! regexp.test(value))
event.recordError(message);
});
@@ -225,11 +259,11 @@
this.result = true;
},
-// Invoked by a validator function (which is passed the event) to record an error
-// for the associated field. The event knows the field and form and invoke's
-// the (added) form method invalidField(). Sets the event's result field to false
-// (i.e., don't allow the form to submit), and sets the event's error field to
-// true.
+ // Invoked by a validator function (which is passed the event) to record an error
+ // for the associated field. The event knows the field and form and invoke's
+ // the (added) form method invalidField(). Sets the event's result field to false
+ // (i.e., don't allow the form to submit), and sets the event's error field to
+ // true.
recordError : function(message)
{
@@ -257,19 +291,19 @@
},
-// Adds a validator. acceptBlank is true if the validator should be invoked regardless of
-// the value. Usually acceptBlank is false, meaning that the validator will be skipped if
-// the field's value is blank. The validator itself is a function that is passed the
-// field's value and the Tapestry.FormEvent object. When a validator invokes event.recordError(),
-// any subsequent validators for that field are skipped.
+ // Adds a validator. acceptBlank is true if the validator should be invoked regardless of
+ // the value. Usually acceptBlank is false, meaning that the validator will be skipped if
+ // the field's value is blank. The validator itself is a function that is passed the
+ // field's value and the Tapestry.FormEvent object. When a validator invokes event.recordError(),
+ // any subsequent validators for that field are skipped.
addValidator : function(acceptBlank, validator)
{
this.validators.push([ acceptBlank, validator]);
},
-// Removes decorations on the field and label (the "t-error" CSS class) and makes the icon
-// invisible. A field that has special decoration needs will override this method.
+ // Removes decorations on the field and label (the "t-error" CSS class) and makes the icon
+ // invisible. A field that has special decoration needs will override this method.
removeDecorations : function(event)
{
@@ -282,9 +316,9 @@
this.icon.hide();
},
-// Adds decorations to the field (including label and icon if present).
-// event - the validation event
-// message - error message
+ // Adds decorations to the field (including label and icon if present).
+ // event - the validation event
+ // message - error message
addDecorations : function(event, message)
{
@@ -303,9 +337,9 @@
},
-// Invoked from the Form's onsubmit event handler. Gets the fields value and invokes
-// each validator (unless the value is blank) until a validator returns false. Validators
-// should not modify the field's value.
+ // Invoked from the Form's onsubmit event handler. Gets the fields value and invokes
+ // each validator (unless the value is blank) until a validator returns false. Validators
+ // should not modify the field's value.
validateInput : function(event)
{
Modified: tapestry/tapestry5/trunk/tapestry-core/src/site/site.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/site/site.xml?rev=594648&r1=594647&r2=594648&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/site/site.xml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/site/site.xml Tue Nov 13 13:34:47 2007
@@ -1,20 +1,20 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
- Copyright 2006, 2007 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.
--->
-
+<!--
+ Copyright 2006, 2007 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.
+-->
+
<project name="Tapestry Core">
<bannerLeft>
<name>Tapestry 5</name>
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/conf/webdefault.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/conf/webdefault.xml?rev=594648&r1=594647&r2=594648&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/conf/webdefault.xml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/conf/webdefault.xml Tue Nov 13 13:34:47 2007
@@ -1,20 +1,20 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
- Copyright 2006 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.
--->
-
+<!--
+ Copyright 2006 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.
+-->
+
<web-app
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/corelib/internal/FormSupportImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/corelib/internal/FormSupportImplTest.java?rev=594648&r1=594647&r2=594648&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/corelib/internal/FormSupportImplTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/corelib/internal/FormSupportImplTest.java Tue Nov 13 13:34:47 2007
@@ -14,7 +14,10 @@
package org.apache.tapestry.corelib.internal;
+import org.apache.tapestry.Field;
import org.apache.tapestry.internal.test.InternalBaseTestCase;
+import org.apache.tapestry.ioc.internal.util.CollectionFactory;
+import org.apache.tapestry.json.JSONObject;
import org.testng.annotations.Test;
public class FormSupportImplTest extends InternalBaseTestCase
@@ -123,10 +126,50 @@
}
catch (IllegalStateException ex)
{
- assertEquals(
- ex.getMessage(),
- "Encoding type of form has already been set to \'foo\' and may not be changed to \'bar\'.");
+ assertEquals(ex.getMessage(),
+ "Encoding type of form has already been set to \'foo\' and may not be changed to \'bar\'.");
}
}
+
+ @Test
+ public void add_validations()
+ {
+ Field barney = newField("barney");
+ Field fred = newField("fred");
+
+ replay();
+
+ FormSupportImpl support = new FormSupportImpl();
+
+ support.addValidation(barney, "required", "Who can live without Barney?", null);
+ support.addValidation(barney, "email", "You know, an e-mail address.", null);
+ support.addValidation(fred, "maxlength", "Up to 10 characters", 10);
+
+ verify();
+
+
+ JSONObject validations = support.getValidations();
+
+ // Tip-toe around the fact that the order of the keys is JDK specific.
+
+ assertEquals(CollectionFactory.newSet(validations.keys()), CollectionFactory.newSet("fred", "barney"));
+
+ assertEquals(validations.get("fred").toString(), "[[\"maxlength\",\"Up to 10 characters\",10]]");
+ assertEquals(validations.get("barney").toString(),
+ "[[\"required\",\"Who can live without Barney?\"],[\"email\",\"You know, an e-mail address.\"]]");
+
+
+ }
+
+ private Field newField(String clientId)
+ {
+ Field field = newMock(Field.class);
+
+ expect(field.getClientId()).andReturn(clientId).atLeastOnce();
+
+ return field;
+ }
+
+
}
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/RunJetty.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/RunJetty.java?rev=594648&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/RunJetty.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/RunJetty.java Tue Nov 13 13:34:47 2007
@@ -0,0 +1,33 @@
+// Copyright 2007 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.tapestry.integration;
+
+import org.apache.tapestry.test.JettyRunner;
+
+/**
+ * Temporary "shim" to run Demo App #1 inside IntelliJ. Eventually, we should write a "Jetty InPlace Integration Plugin"
+ * that works like JettyLauncher for Eclipse.
+ */
+public class RunJetty
+{
+ public static void main(String[] args) throws InterruptedException
+ {
+ JettyRunner runner = new JettyRunner("/", 8080, "src/test/app1");
+
+ Thread.sleep(Long.MAX_VALUE);
+
+ runner.stop();
+ }
+}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/ReturnTypes.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/ReturnTypes.java?rev=594648&r1=594647&r2=594648&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/ReturnTypes.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/ReturnTypes.java Tue Nov 13 13:34:47 2007
@@ -1,17 +1,17 @@
-// Copyright 2007 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.
-
+// Copyright 2007 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.tapestry.integration.app1.pages;
import org.apache.tapestry.ComponentResources;
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/bindings/StringHolder.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/bindings/StringHolder.java?rev=594648&r1=594647&r2=594648&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/bindings/StringHolder.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/bindings/StringHolder.java Tue Nov 13 13:34:47 2007
@@ -1,17 +1,17 @@
-// Copyright 2006, 2007 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.
-
+// Copyright 2006, 2007 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.tapestry.internal.bindings;
public interface StringHolder