Uploaded image for project: 'Struts 1'
  1. Struts 1
  2. STR-2142

Replacement of LookupDispatchAction

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.1.0
    • None
    • Extras
    • None
    • Operating System: All
      Platform: All
    • 30292

    Description

      LookupDispatchAction is useful as a DispatchAction when you have multiple
      buttons on the same form. However, I think another powerful way to solve this
      problem could be used: select a method from a list defined in the mapping
      parameter attribute by checking the presence of o request parameter name.
      See the following cut'n pasted javadoc for details, and see the following
      attachment for an implementation.

      /**

      • This class has the same goal as the DispatchAction: select the appropriate
      • method to execute based on a request parameter. The way to determine which
      • method to call works in a different way, though. The parameter attribute of
      • the mapping contains a list of method names. If one of the request parameters
      • has the same name as one of the method names specified in the list of method
      • names, this method is executed. If none of the request parameters has one
      • of the method names, the unspecified method is invoked. <br />
      • This class has the same goal and utility as the LookupDispatchAction: it
      • allows having several submit buttons on the same form. All that is needed with
      • this class is to give each button a different name (example: preview/post).
      • It's more powerful than the LookupDispatchAction for several reasons, though:
      • <ul>
      • <li>The submit buttons don't need to be declared in the various
      • internationalized ApplicationResources.properties files (useful if JSTL
      • tags are preferred to the Struts tags)</li>
      • <li>It's more performant</li>
      • <li>Two submit buttons may have the same text</li>
      • <li>Links can easily use this kind of action as well as buttons
      • (ex: doThis.do?preview=&subject=...)</li>
      • <li>Hidden fields may easily be used to select the method
      • (ex: <input type="hidden" name="preview"/> )</li>
      • <li>There is no need for the developer to override any abstract method</li>
      • </ul>
      • @author Jean-Baptiste Nizet
        */

      Attachments

        1. ASF.LICENSE.NOT.GRANTED--SelectAction.java
          15 kB
          Michael Jouravlev
        2. ASF.LICENSE.NOT.GRANTED--SelectAction.java
          9 kB
          Michael Jouravlev
        3. ASF.LICENSE.NOT.GRANTED--SelectAction.java
          13 kB
          Michael Jouravlev
        4. ASF.LICENSE.NOT.GRANTED--SelectAction.java
          13 kB
          Michael Jouravlev
        5. ASF.LICENSE.NOT.GRANTED--SelectAction.java
          13 kB
          Michael Jouravlev
        6. ASF.LICENSE.NOT.GRANTED--SelectAction.java
          14 kB
          Michael Jouravlev
        7. ASF.LICENSE.NOT.GRANTED--SelectAction.java
          14 kB
          Michael Jouravlev
        8. ASF.LICENSE.NOT.GRANTED--strings_properties_patchfile.txt
          0.8 kB
          Michael Jouravlev
        9. ASF.LICENSE.NOT.GRANTED--ParameterDispatchAction.java
          9 kB
          Michael Jouravlev
        10. ASF.LICENSE.NOT.GRANTED--ParameterDispatchAction.java
          4 kB
          Jean-Baptiste Nizet

        Issue Links

          Activity

            People

              dsevans93 David Evans
              jnizet Jean-Baptiste Nizet
              Votes:
              2 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: