Uploaded image for project: 'Tapestry 5'
  1. Tapestry 5
  2. TAP5-2383

Serverside publish / subscribe mechanism

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Resolved
    • Minor
    • Resolution: Won't Fix
    • None
    • None
    • tapestry-core
    • 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

          Activity

            People

              Unassigned Unassigned
              uklance Lance S
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: