Announcement Announcement Module
No announcement yet.
Action (postback) not executing after rendering response Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Action (postback) not executing after rendering response


    The issue I'm about to expose is quite exactly the same as:
    However, the JIRA issue I just linked mentions that the issue has been fixed on SWF 2.0.0, and I am experiencing it on SWF 2.0.6-RELEASE.

    Basically, if an action ends up generating the response itself and then calling recordResponseComplete() (exactly as documented here, under "Streaming actions"), then the next "action" generated on the view will be ignored.
    (For example, if user clicks on a link that ends up returning a "Download file" dialog, the user will then have to click on any link on the same page 2 times before the associated action is executed).

    I think I have identified the source of the problem, and came up with a simple fix:

    When renderResponse() is called (by WebFlow), FlowFacesContext executes the following line:
    // stored in flash scope to survive a redirect when transitioning from one view to another
    context.getFlashScope().put(RENDER_RESPONSE_KEY, Boolean.TRUE);
    The problem seems to come from the following 2 facts:
    1. If flashScope.{RENDER_RESPONSE_KEY} is true, a submitted user event does not get processed (see JsfView.processUserEvent())
    2. Since WebFlow did not take care of the RENDER phase (our custom action actually generated the response), then WebFlow did not clear the flashScope

    The fix becomes clear and simple: simply clear the flashScope after having successfully rendered the view.
    In my case, this turned out to adding the 2nd 'evaluate' tag in the following transition:
    <transition on="generatePDF">
        <!-- The following action generates the PDF and injects in the HttpServletResponse -->
        <evaluate expression="generator.generatePDF()" />
        <!-- The fix. -->
        <evaluate expression="flashScope.clear()" />

    I tested the fix and it works.
    I have not submitted any JIRA issues, since I'd like to know if anyone gets the same issue with the latest SWF release.

    Also, I am not exactly convinced whether it really is an issue or not. Perhaps renderResponse() should not write a flag in the flashScope, or the documentation should simply state that an action generating the response is responsible of clearing the flashScope?
    Last edited by angrysoul; Feb 15th, 2011, 04:03 PM.