最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - CustomExpression in DynamicJasper Not Working - Stack Overflow

programmeradmin0浏览0评论

I am trying to print a column in DynamicJasper using conditional expression.

AbstractColumn cAmountCurrent = ColumnBuilder.getNew()
        .setCustomExpression(new ConditionalExpressionTitleAmount())
        .setColumnProperty("reportId", String.class.getName())
        .setTitle(sc.fsStatementYear())
        .setWidth(DJStyles.DOC_NUMBER_COLUMN)
        .setStyle(DJStyles.DETAIL_STYLE_NUM)
        .build();

Here is my ConditionalExpressionTitleAmount class:

public class ConditionalExpressionTitleAmount implements CustomExpression {

    public ConditionalExpressionTitleAmount() {
        System.out.println("ConditionalExpressionTitleAmount created: ");
    }

    @Override
    public Object evaluate(Map fields, Map variables, Map parameters) {
        System.out.println("Inside Evaluate");
        return "Evaluated";

    }

    @Override
    public String getClassName() {
        return String.class.getName();
    }
}

But in the report all I get is blanks. Whereas I am expecting to print "Evaluated" returned by expression.

One important thing is evaluate( ) never gets called as "Inside Evaluate" never gets printed. I do get "ConditionalExpressionTitleAmount created:" on the console though.

发布评论

评论列表(0)

  1. 暂无评论