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

includeProperties Does Not Work with a List of Lists

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 2.3.16
    • 6.5.0
    • Plugin - JSON

    Description

      I found this issue when using server-side processing with JQuery Datatables and attempting to populate.

      Say I have this getter/field on my action:

      public List<List<String>> getListOfLists() {
      	return listOfLists;
      }
      

      My struts.xml is defined as follows:

      <action name="GetData" method="loadData"
      class="com.example.web.action.WebAction">
      	<result type="json" >
      		<param name="ignoreHierarchy">false</param>
      		<param name="includeProperties">listOfLists\[\d+\]\[\d+\]</param>
      	</result>
      </action>
      

      However, the include patterns that are constructed within JSONUtil are not accurate. Instead of making the expected pattern that would work:

      listOfLists
      listOfLists\[\d+\]
      listOfLists\[\d+\]\[\d+\]
      

      Only the following are created:

      listOfLists\[\d+\]
      listOfLists\[\d+\]\[\d+\]
      

      Because the first "listOfLists" is not created, the property is excluded in the results.

      This all happens because of line 463 in JSONUtil:

      addPattern(results, patternExpr.substring(0, patternExpr.lastIndexOf(includePatternData.get(ARRAY_BEGIN_STRING).get(type))), type);
      

      Since we're going at the last index of the ARRAY_BEGIN_STRING string, it's skipping the first index. This could be updated to be smarter to build the include patterns as expected.

      Attachments

        Activity

          People

            Unassigned Unassigned
            albernhagen Andrew Bernhagen
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - 24h
                24h
                Remaining:
                Remaining Estimate - 24h
                24h
                Logged:
                Time Spent - Not Specified
                Not Specified