Package com.javaeye.jert.action.user.report

Source Code of com.javaeye.jert.action.user.report.GenerateReport

package com.javaeye.jert.action.user.report;

import com.javaeye.jert.domain.ReportInstance;
import com.javaeye.jert.domain.query.QueryParameter;

/**
* @author Quake Wang
* @since 2004-12-27
* @version $Revision: 1.6 $
*/
public class GenerateReport extends BaseReportAction {
    protected ReportInstance reportInstance = new ReportInstance();

    public String execute() throws Exception {
        if(!isValidateParameters()) return INPUT;
        reportInstance.setCountOnEachPage(userPrefs.getCountOnEachPage().intValue());
        reportInstance.setReportDefinition(reportDefinition);
        reportInstance.generateItems(parameters);
        return SUCCESS;
    }
   
    //TODO can we move this validation to the xwork validate framework?
    protected boolean isValidateParameters() {
        boolean pass = true;
        for (int i = 0; i < parameters.length; i++) {
            QueryParameter parameter = parameters[i];
            if(!parameter.getParameterDefinition().isOptional() && parameter.getQueryValue() == null){
                addActionError(parameter.getParameterDefinition().getName() + " is required");
                //addFieldError("parameters[" + i + "].value", "required");
                pass = false;
            }
        }
        return pass;
    }

    public ReportInstance getReportInstance() {
        return reportInstance;
    }

    public void setReportInstance(ReportInstance reportInstance) {
        this.reportInstance = reportInstance;
    }
}
TOP

Related Classes of com.javaeye.jert.action.user.report.GenerateReport

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.