All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ar.com.fdvs.dj.core.DJDefaultScriptlet Maven / Gradle / Ivy

Go to download

DynamicJasper (DJ) is an API that hides the complexity of Jasper Reports, it helps developers to save time when designing simple/medium complexity reports generating the layout of the report elements automatically. It creates reports dynamically, defining at runtime the columns, column width (auto width), groups, variables, fonts, charts, crosstabs, sub reports (that can also be dynamic), page size and everything else that you can define at design time. DJ keeps full compatibility with Jasper Reports since it's a tool that helps create reports programmatically in a easy way (it only interferes with the creation of the report design doing the layout of the elements). You can use the classic .jrxml files as templates while the content and layout of the report elements are handled by the DJ API. http://dynamicjasper.com

There is a newer version: 5.3.9
Show newest version
package ar.com.fdvs.dj.core;

import net.sf.jasperreports.engine.JRDefaultScriptlet;
import net.sf.jasperreports.engine.JRParameter;
import net.sf.jasperreports.engine.JRScriptletException;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.fill.JRFillField;
import net.sf.jasperreports.engine.fill.JRFillGroup;
import net.sf.jasperreports.engine.fill.JRFillParameter;
import net.sf.jasperreports.engine.fill.JRFillVariable;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.util.Map;

/**
 * This class handles parameter passing to custom expressions in runtime (during report fill)
 *
 * @author mamana
 */
public class DJDefaultScriptlet extends JRDefaultScriptlet {

    public DJDefaultScriptlet() {
        super();
    }

    private static final Log logger = LogFactory.getLog(DJDefaultScriptlet.class);


    protected FieldMapWrapper fieldMapWrapper = new FieldMapWrapper();
    protected ParameterMapWrapper parameterMapWrapper = new ParameterMapWrapper();
    protected VariableMapWrapper variableMapWrapper = new VariableMapWrapper();

    public void setData(Map parsm, Map fldsm, Map varsm, JRFillGroup[] grps) {
        super.setData(parsm, fldsm, varsm, grps);
        putValuesInMap();
    }

    protected void putValuesInMap() {
        fieldMapWrapper.setMap(this.fieldsMap);
        parameterMapWrapper.setMap(this.parametersMap);
        variableMapWrapper.setMap(this.variablesMap);
    }

    public Map getCurrentFields() {
        return fieldMapWrapper;
    }

    public Map getPreviousFields() {
        return fieldMapWrapper.getPreviousValues();
    }

    public Map getCurrentParams() {
        return parameterMapWrapper;
    }

    public Map getCurrentVariables() {
        return variableMapWrapper;
    }

    @Override
    public void beforeReportInit() throws JRScriptletException {
        super.beforeReportInit();
        JasperReport jr = (JasperReport) getParameterValue(JRParameter.JASPER_REPORT);
        variableMapWrapper.setReportName(jr.getName());
        parameterMapWrapper.setReportName(jr.getName());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy