Skip to content

Commit

Permalink
WW-5455 Uses defaultDelimiter as more meaningful name
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszlenart committed Dec 19, 2024
1 parent e89a357 commit 9ed6485
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@ public interface JasperReport7Aware {
*
* @param invocation current {@link ActionInvocation}
*/
void beforeReportGeneration(ActionInvocation invocation) throws StrutsException;
default void beforeReportGeneration(ActionInvocation invocation) throws StrutsException {
}

/**
* Used to perform an action before report is going to be generated
*
* @param invocation current {@link ActionInvocation}
*/
void afterReportGeneration(ActionInvocation invocation, JasperReport jasperReport) throws StrutsException;
default void afterReportGeneration(ActionInvocation invocation, JasperReport jasperReport) throws StrutsException {
}

/**
* Allows to specify action specific CSV delimiter, if returns null,
Expand All @@ -51,7 +53,8 @@ default String getCsvDelimiter(ActionInvocation invocation) {
}

/**
* Allows to specify different local than used by framework or action
* Allows to specify different local than used by the framework or an action
*
* @param invocation current {@link ActionInvocation}
* @return locale or null
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public interface JasperReport7Constants {
/**
* Allows to define a custom default delimiter when exporting report into CSV file
*/
String STRUTS_JASPER_REPORT_CSV_DELIMITER = "struts.jasperReport7.csv.delimiter";
String STRUTS_JASPER_REPORT_CSV_DELIMITER = "struts.jasperReport7.csv.defaultDelimiter";

/**
* Allows to define a custom url to image servlet used when exporting report into HTML
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ protected void applyTimeZone(ActionInvocation invocation, Map<String, Object> pa
}
}

@SuppressWarnings("unchecked")
protected void applyCustomParameters(ValueStack stack, Map<String, Object> parameters) {
boolean evaluated = parsedReportParameters != null && !parsedReportParameters.equals(reportParameters);
boolean reevaluate = !evaluated || isAcceptableExpression(parsedReportParameters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@ public class JasperReport7CsvExporterProvider implements JasperReport7ExporterPr
/**
* A delimiter used when generating CSV report. By default, "," is used.
*/
private String delimiter = ",";
private String defaultDelimiter = ",";

public JasperReport7CsvExporterProvider() {
}

public JasperReport7CsvExporterProvider(
@Inject(value = JasperReport7Constants.STRUTS_JASPER_REPORT_CSV_DELIMITER, required = false)
String delimiter
String defaultDelimiter
) {
if (StringUtils.isNoneEmpty(delimiter)) {
LOG.debug("Using custom delimiter [{}]", delimiter);
this.delimiter = delimiter;
if (StringUtils.isNoneEmpty(defaultDelimiter)) {
LOG.debug("Using custom delimiter [{}]", defaultDelimiter);
this.defaultDelimiter = defaultDelimiter;
}
}

Expand All @@ -72,8 +72,8 @@ public JRCsvExporter createExporter(ActionInvocation invocation, JasperPrint jas
if (invocation.getAction() instanceof JasperReport7Aware action) {
reportDelimiter = action.getCsvDelimiter(invocation);
}
if (reportDelimiter == null) {
reportDelimiter = delimiter;
if (StringUtils.isEmpty(reportDelimiter)) {
reportDelimiter = defaultDelimiter;
}
LOG.debug("Using delimiter: [{}]", reportDelimiter);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"https://struts.apache.org/dtds/struts-6.0.dtd">

<struts>
<constant name="struts.jasperReport7.csv.delimiter" value=","/>
<constant name="struts.jasperReport7.csv.defaultDelimiter" value=","/>

<bean name="pdf"
class="org.apache.struts2.views.jasperreports7.export.JasperReport7PdfExporterProvider"
Expand Down

0 comments on commit 9ed6485

Please sign in to comment.