4 Replies Latest reply on Feb 18, 2008 1:59 PM by Pete Muir

    Events not appearing.

    Tony Herstell Master

      I have an entity


      @SuppressWarnings("serial")
      @Entity
      @Name("bookingResourceArena")
      @DiscriminatorValue("WithArena")
      public class BookingResourceWithRiders extends BookingResourceWithHoursRange implements Serializable {
      



      with a method:


      @RaiseEvent(value="numbersChanged")
              public void setRiders(int number) {
                      this.riders = number;
              }



      I expected it to throw an event to be caught in a controller bean:


      @Stateful
      @Name("bookingController")
      @Conversational
      public class BookingControllerImpl implements BookingController, Serializable {



      in this method:


      @Observer("numbersChanged")
              public void handleNumbersChanged() {
                      log.info("<>handleNumbersChanged");
              }



      I have NOT added anyting to components.xml (as per the doco).


      I am not seeing the event.


      Any ideas what the voodoo required is?


        • 1. Re: Events not appearing.
          Tony Herstell Master

          I managed to get the event to fire by altering the 'firing' code to :



               public void setRiders(int number) {
                    this.riders = number;
                    Events.instance().raiseEvent("numbersChanged");
               }



          Is this a BUG?


          Now since this is being ultimately driven from Ajax (RF).. you quite often get a few calls for the same click on the UI.
          The Event is only raised for the FIRST event.. which annoyingly always has the number 1 !!!


          In the debugger I can see the second call come though to setRiders with the number 4 (in this case), but the event numbersChanged is not raised again...


          Is this a BUG?

          • 2. Re: Events not appearing.
            Tony Herstell Master

            Darn; I cant hack it like this as for some reason it wont throw the  event as somehow it seems to know it's the second time in the routine during this cycle



                 public void setRiders(int number) {
                      this.riders = number;
                      if (riders!=1) {
                           Events.instance().raiseEvent("numbersChanged");
                      }
                 }



            Any suggestions on either a fix or how to reset this invisible counter would be appreciated (its a nasty hack so a solution would be preferable).

            • 3. Re: Events not appearing.
              Tony Herstell Master
              Using a side effect of another call (that really should even be called) I have hacked it:

              `@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
                   public void setReason(BookingReasonsKind reason) {
                        log.info(">setReason");
                        booking.setReason(reason);
                        
                        // HACKITY HACK
                        handleNumbersChanged();`

              Nice to see if there is a solution.

              In case it helps... this is all Ajaxified and the source UI is :

              `<!-- 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>
              • 4. Re: Events not appearing.
                Pete Muir Master

                Please file a JIRA with a simple runnable test for us to look at.