Struts 2
  1. Struts 2
  2. WW-3024

Validation XML file names when action name has slashes

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.6
    • Fix Version/s: 2.1.8
    • Component/s: XML Validators
    • Labels:
      None
    • Environment:

      struts 2.1.6, Tomcat 6.0, Spring 2.5.6

    • Flags:
      Patch

      Description

      I have a generic struts.xml action configuration as follows:
      ...
      <constant name="struts.enable.SlashesInActionNames" value="true"/>
      ...
      <action name="//*" method="

      {3}

      "
      class="

      {1}Controller">
      <result name="Search">/{1}

      /search

      {2}.jsp</result>
      <result name="Not Found">/{1}/search{2}

      .jsp</result>
      <result name="List">/

      {1}/list{2}.jsp</result>
      <result name="Show">/{1}

      /show

      {2}.jsp</result>
      <result name="Edit">/{1}/edit{2}

      .jsp</result>
      <result name="input">/

      {1}

      /edit

      {2}

      .jsp</result>
      </action>

      I want to add validation XML for specific contexts by setting up validation.xml files. Unfortunately the invocation context in this case contains slashes so that the name of the file that the validation framework is looking for is invalid. For instance if I was executing the action posting/Posting/save on the action class PostingController then I want the validation.xml to be named:

      PostingController-posting-Posting-save-validation.xml rather

      rather than:

      PostingController-posting/Posting/save-validation.xml

      which is an invalid file name. To achieve this I propose that the following method defined at line 205 of com.opensymphony.xwork2.validator.AnnotationActionValidatorManager be changed from:

      private List<ValidatorConfig> buildAliasValidatorConfigs(Class aClass, String context, boolean checkFile)

      { String fileName = aClass.getName().replace('.', '/') + "-" + context + VALIDATION_CONFIG_SUFFIX; return loadFile(fileName, aClass, checkFile); }

      to

      private List<ValidatorConfig> buildAliasValidatorConfigs(Class aClass, String context, boolean checkFile)

      { String fileName = aClass.getName().replace('.', '/') + "-" + context.replace('/', '-') + VALIDATION_CONFIG_SUFFIX; return loadFile(fileName, aClass, checkFile); }

        Activity

        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        42d 12h 44m 1 musachy 18/Apr/09 20:14
        Resolved Resolved Closed Closed
        1289d 2h 53m 1 Lukasz Lenart 28/Oct/12 22:07
        Lukasz Lenart made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Jeff Turner made changes -
        Project Import Mon Feb 01 01:17:42 UTC 2010 [ 1264987062082 ]
        Wes Wannemacher made changes -
        Fix Version/s 2.1.8 [ 21920 ]
        Fix Version/s 2.1.7 [ 21907 ]
        musachy made changes -
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Hide
        musachy added a comment -

        Fixed in xwork trunk r1973. thanks for reporting

        Show
        musachy added a comment - Fixed in xwork trunk r1973. thanks for reporting
        musachy made changes -
        Field Original Value New Value
        Fix Version/s 2.1.7 [ 21907 ]
        Hide
        musachy added a comment -

        I agree with the proposed solution. Moving to 2.1.7

        Show
        musachy added a comment - I agree with the proposed solution. Moving to 2.1.7
        Peter Kelley created issue -

          People

          • Assignee:
            Unassigned
            Reporter:
            Peter Kelley
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development