简体   繁体   English

从挂毯组件监听弹簧事件

[英]Listening spring event from tapestry component

First of all, sorry if I do something wrong, it's my first post on stackOverflow.首先,对不起,如果我做错了什么,这是我在 stackOverflow 上的第一篇文章。 Now, my question:现在,我的问题:

Is it possible to listen to an event thowed by Spring in Tapestry component?是否可以在 Tapestry 组件中监听 Spring 抛出的事件? The event (ShopChangedEvent ) is published with ApplicationEventPublisher, from a Spring front service, and i want to listen to this event in a front Tapestry component.事件 (ShopChangedEvent) 是使用 ApplicationEventPublisher 发布的,来自 Spring 前端服务,我想在前端 Tapestry 组件中收听此事件。 I tried adding"implements ApplicationListener" to my Tapestry component and overriding the onApplicationEvent method.我尝试将“实现 ApplicationListener”添加到我的 Tapestry 组件并覆盖 onApplicationEvent 方法。

Thank for all,谢谢大家,

Alberto阿尔贝托

It's possible, but it's probably not what you want.这是可能的,但这可能不是您想要的。

Tapestry components "live" in the scope of HTTP requests. Tapestry 组件在 HTTP 请求范围内“存活”。 Every time you use a UI component in a TML-markup Tapestry creates just one instance of that component and shares it across all HTTP requests.每次在 TML 标记 Tapestry 中使用 UI 组件时,只创建该组件的一个实例,并在所有 HTTP 请求中共享它。

So even if you subscribe your UI component to ApplicationEventPublisher you won't be able to properly "receive" an event in the right request cycle.因此,即使您将 UI 组件订阅到ApplicationEventPublisher您也无法在正确的请求周期中正确“接收”事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM