Hi everyone,
    I'm working on some small application, and I need to register every user
action into a proprietary module. I need to record the total time consumed
by a request, the action that triggered the event and some http parameters.
The Tapestry version is 5.0.18, under Jboss 4.0.5.

To avoid code duplication I thought to use some kind of request filter, for
page rendering and ajax requests both... I read the APIs and found
ComponentEventRequestFilter, which works fine when the URL change. But I
can't find a similar class for the Ajax events! I found AjaxFilter /
AjaxComponentEventRequestHandler .. but they are under the
org.apache.tapestry5.internal.services package, which is bad to use - and
they don't work. 
I get this error when I start jboss: java.lang.RuntimeException: Service id
'AjaxComponentEventRequestHandler' has already been defined by
org.apache.tapestry5.services.TapestryModule.buildAjaxComponentEventRequestHandler(List,
Logger, ServiceResources) (at TapestryModule.java:1267) and may not be
redefined by [myapp].AppModule.buildAjaxComponentEventRequestHandler(List,
Logger, ServiceResources) (at AppModule.java:127). You should rename one of
the service builder methods.
        at
org.apache.tapestry5.ioc.internal.RegistryImpl.<init>(RegistryImpl.java:170)
        at 
org.apache.tapestry5.ioc.RegistryBuilder.build(RegistryBuilder.java:168)
        at
org.apache.tapestry5.internal.TapestryAppInitializer.getRegistry(TapestryAppInitializer.java:146)
        at org.apache.tapestry5.TapestryFilter.init(TapestryFilter.java:80)
        at
org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:223)

This is what I put in the AppModule:

        public void
contributeComponentEventRequestHandler(OrderedConfiguration<ComponentEventRequestFilter>
configuration,
                    @InjectService("AjaxComponentEventFilter") AjaxFilter 
compFilter) {
                  configuration.add("ajaxComponentEventFilter", compFilter);
        }

[...]

        public AjaxFilter buildAjaxComponentEventRequestHandler(
                        final List<ComponentEventRequestFilter> configuration,
                        final Logger logger, final ServiceResources resources) {
                return new AjaxFilter(null, null) {
                        public void handle(ComponentEventRequestParameters 
parameters,
                                        @Ajax ComponentEventRequestHandler 
handler)
                                        throws IOException {

                                System.out.println("Before handle");
                                handler.handle(parameters);
                                System.out.println("After handle");
                        }
                };
        }

I also tried to write a ComponentEventRequestFilter with the @Ajax
annotation on the ComponentEventRequestHandler... but it doesn't intercept
anything:

        public ComponentEventRequestFilter buildMyComponentEvent(final Logger 
log,
                        final RequestGlobals globals) {
                return new ComponentEventRequestFilter() {

                        public void handle(ComponentEventRequestParameters 
parameters,
                                        @Ajax
                                        ComponentEventRequestHandler handler) 
throws IOException {
                                long millis1 = System.currentTimeMillis();
                                handler.handle(parameters);
                                long millis2 = System.currentTimeMillis();
                        }
                };
        }


How could I workaround this problem? Is there a better way to solve my
issue? 

Thanks in advance, Andrea

--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/filtering-Ajax-requests-tp4507057p4507057.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to