I tried to create multiple JRConditionalStyle in Java code for the Jasper report.
private JRDesignStyle getThicknessMeasureStyle(String fieldName, String fieldName1, String fieldName2, JRDesignStyle parentStyle) {
JRDesignStyle jrDesignStyle = new JRDesignStyle();
jrDesignStyle.setName(fieldName + "Style");
jrDesignStyle.setParentStyle(parentStyle);
String prefix = "placethicknesstmlpoint.";
List<String> values = getValues();
for (int i=0; i<3; i++) {
JRDesignConditionalStyle conditionalStyle = new JRDesignConditionalStyle();
conditionalStyle.rename("Style" + i);
JRDesignExpression conditionExpression = new JRDesignExpression();
conditionExpression.setText(String.format("method1.cal($F{%s}, $F{%s, %F{%s}}).equals(${%s})", fieldName, fieldName1, fieldName2, values(i));
conditionalStyle.setConditionExpression(conditionExpression);
conditionalStyle.setBackcolor(#123456);
conditionalStyle.setMode(OPAQUE);
jrDesignStyle.addConditionalStyle(conditionalStyle);
}
return jrDesignStyle;
}
error
net.sf.jasperreports.engine.design.JRValidationException: Report design not valid :
1. Field name missing.
Stanger thing is I tried to write this JRDesignExpression in the jrxml file, it works
New contributor
Run Zhang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.