struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paolo Lutterotti (JIRA)" <>
Subject [jira] Created: (WW-3397) IncludeProperties within Json plugin are not handled properly with patterns including arrays
Date Fri, 26 Feb 2010 10:53:27 GMT
IncludeProperties within Json plugin are not handled properly with patterns including arrays

                 Key: WW-3397
             Project: Struts 2
          Issue Type: Bug
          Components: Other
    Affects Versions: 2.1.8
            Reporter: Paolo Lutterotti

In order to repeat the error (on version struts2-json-plugin-2.1.8 ) it's enough to use a
regexp pattern like this(in general the use of array \[\d+\] should be not at the first level,
but deeper):
<param name="includeProperties">							
This pattern aims to extract a name property given this structure:
1)The Action has a getter:
OperatorsDTO getOperatorsgrid(){};
2)OperatorsDTO is defined as:
class OperatorsDTO{
   public List<Operators> getItems(){}
3)Each Operator bean has (among others) a getName() method returning a String

With this configuration, the JSON created will be empty (just {"operatorsgrid":{}} ).
The problem has to be found in the method setIncludeProperties() of org.apache.struts2.json.JSONResult
Given the above regexp, this method produces this list of patterns:
[operatorsgrid, opera, operatorsgrid\.items\[\d+\], operatorsgrid\.items\[\d+\]\.name]
Clearly there is the lack of one fundamental item: operatorsgrid\.items . Without this, the
property items won't be explored. moreover there is another item "opera" which apparently
is meaningless.
The error is at line 160:
  this.includeProperties.add(Pattern.compile(patternExpr.substring(0, patternPiece
patternPiece is already a substring of  patternExpr (line 151) so if this lines aims to add
a new pattern which just excludes the las \[\d+\], it should be changed to:
this.includeProperties.add(Pattern.compile(patternExpr.substring(0, patternExpr
Given this, the new pattern set becomes:
[operatorsgrid, operatorsgrid\.items, operatorsgrid\.items\[\d+\], operatorsgrid\.items\[\d+\]\.name]
now the "opera" is vanished while we have operatorsgrid\.items which allows to dig into Operators

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message