2 Replies Latest reply on Feb 1, 2008 11:38 PM by Tony Herstell

    Events..

    Tony Herstell Master

      I have an Entity and am trying to get it to throw an event when the number of riders changes (this is mapped to the View naturally)...

      I have tried with just two annotation (thrower and catcher) to no avail... now I have added EVERYTHING in and it still does not work; what am I missing?

      Entity...

      @SuppressWarnings("serial")
      @Entity // Defines this as an Entity that is a class mapped to the Datastore.
      @Name("bookingResourceArena") // Name used within SEAM for an instance of this class.
      @DiscriminatorValue("WithArena")
      public class BookingResourceWithRiders extends BookingResourceWithHoursRange implements Serializable {
      
      ...
      
       @RaiseEvent("RiderNumbersChanged")
       public void setRiders(int number) {
       this.riders = number;
       Events.instance().raiseEvent("RiderNumbersChanged");
       }
      


      Controller...
      @SuppressWarnings("serial")
      @Stateful
      // A new component is created or re-initialised and re-used each time it is
      // called.
      @Name("bookingController")
      // Name used within SEAM for an instance of this class.
      @Conversational
      // Scope that this class exists in.
      public class BookingControllerImpl implements BookingController, Serializable {
      
      ...
      
       @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
       @Observer("RiderNumbersChanged")
       public void changeRiderNumbers() {
       log.info(">changeRiderNumbers");
       log.info("<changeRiderNumbers");
       }
      


      components.xml
       <event type="RiderNumbersChanged">
       <action expression="#{bookingController.changeRiderNumbers}" />
       </event>
      



      Chunk off screen
      <!-- Number of Riders (Arenas) -->
      <rich:column colspan="3" breakBefore="true"
       rendered="#{(bookingController.reason == 'ONE_HOUR_PRIVATE' || bookingController.reason == 'ONE_HOUR_OPEN')
       and (eachResource.resource.kind == 'INDOOR_ARENA' || eachResource.resource.kind == 'DRESSAGE_ARENA' || eachResource.resource.kind == 'SJ_ARENA')}">
       <h:outputText value="#{messages.booking_number_of_riders}" />
       <rich:inputNumberSpinner id="riderNumbers" immediate="true" enableManualInput="false"
       minValue="1" maxValue="6" step="1" value="#{eachResource.riders}">
       <a4j:support event="onchange" eventsQueue="eventsQueue" requestDelay="2000" />
       </rich:inputNumberSpinner>
      </rich:column>
      


        • 1. Re: Events..
          Tony Herstell Master

          Not to worry I have found it works when richfaces is displaying a list of ithems in a datatable and there is another item in the list AFTER the one that is supposed to raise the event.
          Too weired for me to track down so done it another way.

          • 2. Re: Events..
            Tony Herstell Master

            Well it's
            Booking->Days->BookingResources
            i.e. Booking -> (List of Days) -> (List of Booking Resource) as Set is not well supported!

            This is shown as a datatable within a datatable in the Richfaces UI...

            Anyhow the BookingResources (Discriminated Entities) can, given the right Resource Type, have Riders which is mapped to a rich:spinner

            The bug was that the spinner only raised events when something came after it in the list... as I said too weired for me to track down so done another way. ..

            Lists of Lists rendered as nested datatables do actually give Richfaces a few problems.


            Should be fun when I go one more level deep to the actual list of riders for each Resource...

            ;)