WW-4064 WW-3698 Adds additional flag to cover both cases

This commit is contained in:
Lukasz Lenart
2014-07-29 10:04:18 +02:00
parent bf6b37f2e3
commit ca50c1aedd
2 changed files with 18 additions and 10 deletions
@@ -155,6 +155,7 @@ public class JasperReportsResult extends StrutsResultSupport implements JasperRe
protected String delimiter;
protected String imageServletUrl = "/images/";
protected String timeZone;
protected boolean wrapField = true;
/**
* Connection which can be passed to the report
@@ -227,6 +228,10 @@ public class JasperReportsResult extends StrutsResultSupport implements JasperRe
this.timeZone = timeZone;
}
public void setWrapField(boolean wrapField) {
this.wrapField = wrapField;
}
public String getReportParameters() {
return reportParameters;
}
@@ -284,7 +289,7 @@ public class JasperReportsResult extends StrutsResultSupport implements JasperRe
Connection conn = (Connection) stack.findValue(connection);
if (conn == null)
stackDataSource = new ValueStackDataSource(stack, dataSource);
stackDataSource = new ValueStackDataSource(stack, dataSource, wrapField);
if ("https".equalsIgnoreCase(request.getScheme())) {
// set the the HTTP Header to work around IE SSL weirdness
@@ -41,12 +41,12 @@ public class ValueStackDataSource implements JRRewindableDataSource {
*/
private static Logger LOG = LoggerFactory.getLogger(ValueStackDataSource.class);
private Iterator iterator;
private ValueStack valueStack;
private String dataSource;
private boolean wrapField;
Iterator iterator;
ValueStack valueStack;
String dataSource;
boolean firstTimeThrough = true;
private boolean firstTimeThrough = true;
/**
* Create a value stack data source on the given iterable property
@@ -54,10 +54,11 @@ public class ValueStackDataSource implements JRRewindableDataSource {
* @param valueStack The value stack to base the data source on
* @param dataSourceParam The property to iterate over for the report
*/
public ValueStackDataSource(ValueStack valueStack, String dataSourceParam) {
public ValueStackDataSource(ValueStack valueStack, String dataSourceParam, boolean wrapField) {
this.valueStack = valueStack;
this.dataSource = dataSourceParam;
this.wrapField = wrapField;
dataSource = dataSourceParam;
Object dataSourceValue = valueStack.findValue(dataSource);
if (dataSourceValue != null) {
@@ -104,9 +105,11 @@ public class ValueStackDataSource implements JRRewindableDataSource {
LOG.debug("Field [#0] = [#1]", field.getName(), value);
}
if (MakeIterator.isIterable(value)) {
if (!wrapField && MakeIterator.isIterable(value) && !field.getValueClass().isInstance(value)) {
return value;
} else if (MakeIterator.isIterable(value)) {
// wrap value with ValueStackDataSource if not already wrapped
return new ValueStackDataSource(this.valueStack, expression);
return new ValueStackDataSource(this.valueStack, expression, wrapField);
} else {
return value;
}