Details
-
New Feature
-
Status: Resolved
-
Minor
-
Resolution: Won't Fix
-
None
-
None
-
None
Description
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.
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 } }
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); } }
If this change was made on ComponentResources, we should probably add the following to support invoking publish events on the client
Link ComponentResources.createPublishLink(String eventType, Object... context)
Attachments
Issue Links
- is superceded by
-
TAP5-2416 Client-side publish/subscribe mechanism
- Open