Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-2635

Flash scope

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • 6.5.0
    • "New" API
    • None
    • Patch

    Description

      I have developed a FlashResult / FlashInterceptor pair to implement "flash" scope in a way that follows the usual Struts2 principles and respects its "feel".

      It basically works like the ServletActionRedirectResult except that instead of converting all extra parameters to strings and adding them as HTTP parameters in the redirect URL, it creates a HashMap using these parameter key/value pairs with no conversion and stores it in the user session. On the next HTTP request the FlashInterceptor, if properly added to the interceptor stack, will retrieve this map and copy the map entries to the target action using the parameter keys. It should work for all data types.

      To function correctly this approach assumes that bug WW-2170 is fixed. The implementation also borrows a lot from the ServletActionRedirectResult and some refactoring should
      be done.

      While there may be issues with flash scope in general with regards to repeated GETs being inconsistent, there are some valid use cases such as when saving messages to be displayed after a redirect. I think it's good for the developer to have this tool and it could make a nice addition to the Struts2 code base.

      Attachments

        1. FlashInterceptor.java
          2 kB
          Guillaume Bilodeau
        2. FlashInterceptorTest.java
          3 kB
          Guillaume Bilodeau
        3. FlashResult.java
          4 kB
          Guillaume Bilodeau
        4. FlashResultTest.java
          7 kB
          Guillaume Bilodeau

        Activity

          People

            Unassigned Unassigned
            gbilodeau Guillaume Bilodeau
            Votes:
            5 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated: