Uploaded image for project: 'Spring Web Flow'
  1. Spring Web Flow
  2. SWF-1500

The @ListenerFor annotation for PostRestoreStateEvent doesn't work with Spring Web Flow



    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Complete
    • Affects Version/s: 2.3.0
    • Fix Version/s: 2.3.1
    • Component/s: JSF
    • Labels:


      The @ListenerFor annotation for PostRestoreStateEvent, as well as some other ones, doesn't work with Spring Web Flow.

      I've tested the @ListenerFor annotation for a custom component in a modified Spring Web Flow sample application, and has found out that it works only for PostAddToViewEvent, but not for PostRestoreStateEvent, which I needed in the first place, and other events as well.

      I've also tried to subscribe to the same events using the subscribeToEvent() method, but it works in the same way as the annotation - only for PostAddToViewEvent

      To doublecheck my findings, I've tried the same component in a simple JSF application without Spring Web Flow, and the PostRestoreStateEvent and other ones (PreValidateEvent, PostValidateEvent) do get invoked, so this confirms that the problem is somehow introduced by using the Spring Web Flow.

      I've attached both of my test projects:

      • the modified SWF "booking-faces" sample, where the problem is reproducible;
      • a simple application named "tmpCheck" without SWF, where PostRestoreState event does get fired properly.

      Here are the changes that I've done to modify the original "booking-faces" SWF sample:

      • Added a very simple one-class org.components.Label component, which uses the @ListenerFor annotation to get component system event notifications;
      • Registered this component at faces-config.xml, and created the tags.taglib.xml file where the tag for this component is registered;
      • Modified the enterSearchCriteria.xhtml page to use the new Label component, and added a test submit button to it.

      Here's how the described bug can be reproduced in the "booking-faces" application attached to this request:

      • Extract the project, build it with "mvn package", and deploy it;
      • Go to http://localhost:8080/swf-booking-faces/spring/intro
      • Click on the "Start your Spring Travel experience" link
      • When the page has been loaded - click the "Submit" button. The Label component prints out its restoreState and processEvent invokations to the console, and in a properly working case we should have seen both the "method restoreState() invoked" message, and a message saying that processEvent for PostRestoreStateEvent has been invoked, but as you can see on the console, we don't receive the PostRestoreStateEvent here, and only PostAddToViewEvent is fired, which is a problem.

      To test "tmpCheck", follow these steps:

      • Extract, build and deploy the project;
      • Go to http://localhost:8080/tmpCheck/index.faces
      • Click on the "Submit" button. Now we can see both the restoreState method invokation notification, and two processEvent method invokations for PostAddToViewEvent and PostRestoreStateEvent, which is correct.


          Issue Links



              rstoya05-aop Rossen Stoyanchev
              andrii.loboda Andrii Loboda
              0 Vote for this issue
              1 Start watching this issue