| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
|
| 20 | |
|
| 21 | |
|
| 22 | |
|
| 23 | |
|
| 24 | |
|
| 25 | |
package org.equanda.tapestry5.services; |
| 26 | |
|
| 27 | |
import org.apache.tapestry5.Translator; |
| 28 | |
import org.apache.tapestry5.ioc.Configuration; |
| 29 | |
import org.apache.tapestry5.ioc.MappedConfiguration; |
| 30 | |
import org.apache.tapestry5.ioc.OrderedConfiguration; |
| 31 | |
import org.apache.tapestry5.ioc.annotations.InjectService; |
| 32 | |
import org.apache.tapestry5.services.*; |
| 33 | |
import org.equanda.tapestry5.bindings.ManifestBindingPrefixFactory; |
| 34 | |
import org.equanda.tapestry5.translators.BooleanTranslator; |
| 35 | |
import org.equanda.tapestry5.translators.DoubleTranslator; |
| 36 | |
import org.equanda.tapestry5.translators.TimestampTranslator; |
| 37 | |
|
| 38 | |
import java.io.IOException; |
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | |
|
| 44 | |
|
| 45 | 0 | public class EquandaModule |
| 46 | |
{ |
| 47 | |
|
| 48 | |
public static void contributeComponentClassResolver( Configuration<LibraryMapping> configuration ) |
| 49 | |
{ |
| 50 | 0 | configuration.add( new LibraryMapping( "equanda", "org.equanda.tapestry5" ) ); |
| 51 | 0 | } |
| 52 | |
|
| 53 | |
|
| 54 | |
|
| 55 | |
|
| 56 | |
|
| 57 | |
|
| 58 | |
|
| 59 | |
|
| 60 | |
public static void contributeTranslatorSource( MappedConfiguration<String, Translator> configuration ) |
| 61 | |
{ |
| 62 | 0 | configuration.add( "double", new DoubleTranslator() ); |
| 63 | 0 | configuration.add( "timestamp", new TimestampTranslator() ); |
| 64 | 0 | configuration.add( "boolean", new BooleanTranslator() ); |
| 65 | 0 | } |
| 66 | |
|
| 67 | |
|
| 68 | |
public static void contributeFactoryDefaults( MappedConfiguration<String, String> configuration ) |
| 69 | |
{ |
| 70 | 0 | configuration.add( "equanda.truncate.default.length", "30" ); |
| 71 | 0 | configuration.add( "equanda.truncate.default.suffix", "..." ); |
| 72 | 0 | configuration.add( "equanda.inlinelinklist.additional.row.count", "5" ); |
| 73 | 0 | configuration.add( "equanda.inlineprimitivelist.additional.row.count", "5" ); |
| 74 | 0 | configuration.add( "equanda.select.rows.per.page", "25" ); |
| 75 | 0 | } |
| 76 | |
|
| 77 | |
public RequestFilter buildUtf8Filter( |
| 78 | |
@InjectService( "RequestGlobals" ) final RequestGlobals requestGlobals ) |
| 79 | |
{ |
| 80 | 0 | return new RequestFilter() |
| 81 | |
{ |
| 82 | 0 | public boolean service( Request request, Response response, RequestHandler handler ) |
| 83 | |
throws IOException |
| 84 | |
{ |
| 85 | 0 | requestGlobals.getHTTPServletRequest().setCharacterEncoding( "UTF-8" ); |
| 86 | 0 | return handler.service( request, response ); |
| 87 | |
} |
| 88 | |
}; |
| 89 | |
} |
| 90 | |
|
| 91 | |
public void contributeRequestHandler( OrderedConfiguration<RequestFilter> configuration, |
| 92 | |
@InjectService( "Utf8Filter" ) final RequestFilter utf8Filter ) |
| 93 | |
{ |
| 94 | 0 | configuration.add( "Utf8Filter", utf8Filter ); |
| 95 | 0 | } |
| 96 | |
|
| 97 | |
|
| 98 | |
|
| 99 | |
|
| 100 | |
|
| 101 | |
|
| 102 | |
public static void contributeBindingSource( MappedConfiguration<String, BindingFactory> configuration ) |
| 103 | |
{ |
| 104 | 0 | configuration.add( "manifest", new ManifestBindingPrefixFactory() ); |
| 105 | 0 | } |
| 106 | |
|
| 107 | |
} |