[
https://issues.apache.org/jira/browse/TAP5-2383?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14121100#comment-14121100
]
Dmitry Gusev commented on TAP5-2383:
------------------------------------
I don't think it's necessary to modify {{ComponentResources}} interface,
because there will/might be cross-page publishing, and it doesn't feel right to
put the publishing logic there.
Also why do we need the {{ComponentResources.createPublishLink}}? How is the
publish event will be different from existing event types?
p.s.
I'm sure you've seen the Publisher service:
https://github.com/anjlab/anjlab-tapestry-commons/blob/master/anjlab-tapestry-commons/src/main/java/com/anjlab/tapestry5/services/events/Publisher.java
-- we're using it in production now, so you might want to try it to see other
features that are implemented there (like limit broadcasting to only
subscribers that are from active page, etc.) and maybe take something from
there to the tapestry core.
p.p.s.
I really like the idea of using @Subscribe instead of pageLoaded(), and I'm
going to borrow it to my Publisher if you don't mind? :)
> Serverside publish / subscribe mechanism
> ----------------------------------------
>
> Key: TAP5-2383
> URL: https://issues.apache.org/jira/browse/TAP5-2383
> Project: Tapestry 5
> Issue Type: New Feature
> Components: tapestry-core
> Reporter: Lance
> Priority: Minor
>
> In some cases, an event in one component should cause an action (eg ajax
> update) in another. When these components are siblings it sometimes gets
> tricky having to pass zone id's around and having one component update the
> other.
> It would be nice to decouple the components with a serverside pub/sub
> mechanism. Here's an initial brain dump on how it could work.
> {code:java}
> public class EditPersonComponent {
> @Parameter
> private Person person;
> @Inject
> private PersonDao personDao;
> @Inject
> private ComponentResources componentResources;
> void onSuccessFromPersonForm() {
> personDao.save(person);
> componentResources.publish("personUpdated", person); // new method on
> ComponentResources
> }
> }
> {code}
> {code:java}
> public class SomeOtherComponent {
> @Inject
> private AjaxResponseRenderer ajaxResponseRenderer;
> @Property
> private Person person;
> @Inject
> private Zone personZone;
> // new subscribe annotation (and naming convention?)
> @Subscribe("personUpdated")
> void onPersonUpdatedPublished(Person person) {
> this.person = person;
> ajaxResponseRenderer.addRender(personZone);
> }
> }
> {code}
> If this change was made on ComponentResources, we should probably add the
> following to support invoking publish events on the client
> {code}
> Link ComponentResources.createPublishLink(String eventType, Object... context)
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)