I see. Davor, this is a great service you're providing on the mailing list.

Corresponding change to MyRequestHandler is to the _productionMode field and the constructor...

    private boolean _productionMode = true;

public MyRequestExceptionHandler(RequestPageCache pageCache, PageResponseRenderer renderer, Logger logger, @Inject @Symbol(TapestryConstants.PRODUCTION_MODE_SYMBOL) boolean productionMode)
    {
        _pageCache = pageCache;
        _renderer = renderer;
        _logger = logger;
        _productionMode = productionMode;
    }

...and the rest just works.

Cheers,

Geoff

On 19/02/2008, at 10:06 PM, Davor Hrg wrote:

you can get it as symbol

contributeAliasOverrides(
   @InjectService("MyRequestExceptionHandler")
RequestExceptionHandler myHandler,
   @Inject @Symbol(TapestryConstants.PRODUCTION_MODE_SYMBOL) boolean
productionMode,
   Configuration<AliasContribution> configuration) {

then pass it to the service


Davor Hrg


On Feb 19, 2008 12:01 PM, Geoff Callender
<[EMAIL PROTECTED]> wrote:
Many thanks, Davor.  Here's what worked to display a custom exception
report page ONLY IF tapestry.production-mode=true.

In services.AppModule:

    public static void bind(ServiceBinder binder) {
        binder.bind(RequestExceptionHandler.class,
MyRequestExceptionHandler.class).withId("MyRequestExceptionHandler");
    }

    public static void
contributeAliasOverrides(@InjectService("MyRequestExceptionHandler")
        RequestExceptionHandler myHandler,
Configuration<AliasContribution> configuration) {

configuration
.add(AliasContribution.create(RequestExceptionHandler.class,
myHandler));
    }

In services.MyRequestHandler, which is identical to Tapestry's
DefaultRequestExceptionHandler except (1) it gets the production-mode
property (couldn't see how to inject it - we're in the services
package here):

    static private final String _productionModeStr =
System.getProperty(TapestryConstants.PRODUCTION_MODE_SYMBOL);
    private boolean _productionMode =
Boolean.parseBoolean(_productionModeStr);

and (2) in its handleRequestException(...) method

    Page page = null;

    if (_productionMode) {
        _logger.error("MyExceptionReport page will be shown.");
        page = _pageCache.get("MyExceptionReport");
    }
    else {
_logger.error("Tapestry ExceptionReport page will be shown.");
        page = _pageCache.get("ExceptionReport");
    }

But I'm still looking forward to the much simpler 
https://issues.apache.org/jira/browse/TAPESTRY-2169

Cheers,

Geoff


On 19/02/2008, at 12:47 AM, Davor Hrg wrote:

Alias,
http://tapestry.apache.org/tapestry5/tapestry-core/guide/alias.html

or

decorate
http://wiki.apache.org/tapestry/Tapestry5HowToDecorateService
http://tapestry.apache.org/tapestry5/tapestry-ioc/decorator.html

Davor hrg

On Feb 18, 2008 2:34 PM, Geoff Callender
<[EMAIL PROTECTED]> wrote:
Thanks again, but sorry - no cigar.

00:27:35,038 ERROR [RequestHandler] Construction of service
RequestHandler failed: Error invoking service builder method
org.apache.tapestry.services.TapestryModule.build(Logger, List,
Dispatcher) (at TapestryModule.java:905) (for service
'RequestHandler'): Error invoking service contribution method
org
.apache
.tapestry
.services
.TapestryModule.contributeRequestHandler(OrderedConfiguration,
Context, RequestExceptionHandler, long, long, LocalizationSetter):
Service interface
org.apache.tapestry.services.RequestExceptionHandler
is matched by 2 services: MyRequestExceptionHandler,
RequestExceptionHandler.  Automatic dependency resolution requires
that exactly one service implement the interface.

The broader question I don't yet grasp is how to override the
implementation of a core service.

As for exception reporting, it occurred to me that it would be much
simpler to solve with a new component.  See what you think of this
thought:

      https://issues.apache.org/jira/browse/TAPESTRY-2169

Cheers,

Geoff


On 19/02/2008, at 12:16 AM, Davor Hrg wrote:

binder.bind(MyRequestExceptionHandler.class);

On Feb 18, 2008 12:00 PM, Geoff Callender
<[EMAIL PROTECTED]> wrote:
Thanks for the quick response, but no joy.  Now it fails when the
first page is requested because now there are 2 implementations of
the
one service.

21:55:24,145 ERROR [RequestHandler] Construction of service
RequestHandler failed: Error invoking service builder method
org.apache.tapestry.services.TapestryModule.build(Logger, List,
Dispatcher) (at TapestryModule.java:905) (for service
'RequestHandler'): Error invoking service contribution method
org
.apache
.tapestry
.services
.TapestryModule.contributeRequestHandler(OrderedConfiguration,
Context, RequestExceptionHandler, long, long, LocalizationSetter):
Service interface
org.apache.tapestry.services.RequestExceptionHandler
is matched by 2 services: MyRequestExceptionHandler,
RequestExceptionHandler. Automatic dependency resolution requires
that exactly one service implement the interface.




On 18/02/2008, at 9:51 PM, Davor Hrg wrote:

binder.bind(RequestExceptionHandler.class,
MyRequestExceptionHandler
.class).withId("MyRequestExceptionHandler");

On Feb 18, 2008 11:42 AM, Geoff Callender
<[EMAIL PROTECTED]> wrote:
I can't find the right way to configure AppModule.  Latest
attempt is
simply to do this:

    public static void bind(ServiceBinder binder) {
            binder.bind(RequestExceptionHandler.class,
MyRequestExceptionHandler.class);
    }

but it seems that's not legal.  Stacktrace snippet is:

21:12:45,403 ERROR [[/jumpstart]] Exception starting filter app
java.lang.RuntimeException: Service id 'RequestExceptionHandler'
has
already been defined by
org
.apache
.tapestry
.internal
.services.DefaultRequestExceptionHandler(RequestPageCache,
PageResponseRenderer, Logger) (at
DefaultRequestExceptionHandler.java:
37) and may not be redefined by jumpstart.web.services.MyRequestExceptionHandler
(RequestPageCache, PageResponseRenderer, Logger) (at
MyRequestExceptionHandler.java:43). You should rename one of the
service builder methods.
    at
org
.apache
.tapestry.ioc.internal.RegistryImpl.<init>(RegistryImpl.java:
174)

Geoff


On 18/02/2008, at 2:00 AM, Davor Hrg wrote:

yes :)

either that,
or pass the value to your ExceptionReporter
and have customized page for both dev and production :)

Davor Hrg

On Feb 17, 2008 2:49 PM, Geoff Callender
<[EMAIL PROTECTED]> wrote:
So you're suggesting that I test the value of the system
property
tapestry.production-mode in AppModule and use it to condition
whether
I contribute an ExceptionReporter.  Is that right?


On 17/02/2008, at 11:49 PM, Davor Hrg wrote:

you can use that symbol in your custom erro page too,
either omit the contribution,
or display different message

On Feb 17, 2008 1:25 PM, Geoff Callender
<[EMAIL PROTECTED]> wrote:
Is there a way to make it use your own custom exception
report
page
only if -Dtapestry.production-mode=true?


On 17/02/2008, at 10:47 PM, Geoff Callender wrote:

I like it - I think it's the right default.  Just need to
make
sure
everyone's aware of it.

Geoff

On 17/02/2008, at 9:58 PM, Davor Hrg wrote:

it's exactly that

On Feb 17, 2008 11:20 AM, Chris Poulsen
<[EMAIL PROTECTED]>
wrote:
Hi,

Could this be related to the introduction of production
mode ?

I had to add:

             <systemProperties>
                 <systemProperty>
                     <name>tapestry.production-mode</
name>
                     <value>false</value>
                 </systemProperty>
             </systemProperties>

Into the maven-jetty-plugin configuration to get the nice
exception page

HTH

--
Chris


Joost Schouten (ml) wrote:
I'm experiencing the same with 5.0.11

Cheers,
Joost

Geoff Callender wrote:
Is anyone else seeing this?  The exception report page
in
T5.0.10 has
no detail - I'm getting only a heading and the
exception,
eg.
An unexpected application exception has occurred.

Render queue error in BeginRender[examples/jodatime/
1:pagelink]:
java.lang.ClassNotFoundException: caught an exception
while
obtaining
a class file for
jumpstart.web.components.DateMidnightField

Cheers,

Geoff


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: users-
[EMAIL PROTECTED]
For additional commands, e-mail: users-
[EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: users- [EMAIL PROTECTED]
For additional commands, e-mail: users-
[EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: users- [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Reply via email to