[ 
https://issues.apache.org/jira/browse/TAP5-2383?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14121140#comment-14121140
 ] 

Lance commented on TAP5-2383:
-----------------------------

Answering some of Dmitry's questions:

{quote}declaration of event handlers (the naming conventions) & event contexts 
will work the same isn't it?{quote}
I don't think so, I think these are different types of events. In my example I 
used a new annotation @Subscribe("personUpdated"). But you could easily pass 
one to the other.

{quote}Wouldn't it be better to just add @Publish or @Broadcast annotation to 
the event handler instead?{quote}
I'm not sure we understand each other here. I'm suggesting a @Subscribe 
annotation for the subscription handler and a service invocation for the 
publish.

{quote}Or/and have the ability to publish the event manually using some new 
service?{quote}
Did you see my code? 
componentResources.publish("personUpdated", person); // new method on 
ComponentResources

{quote}And usually you want to do this conditionally{quote}
As I said, publishing is a service invocation. Invoke it when and where you 
need.



> 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;
>    // lets assume there's a form in the component which gets posted
>    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)

Reply via email to