Jump to content
We've recently updated our Privacy Statement, available here ×

richardc

Members
  • Posts

    26
  • Joined

  • Last visited

 Content Type 

Profiles

Forum

Events

Featured Visualizations

Knowledge Base

Documentation (PDF Downloads)

Blog

Documentation (Test Area)

Documentation

Dr. Jaspersoft Webinar Series

Downloads

Posts posted by richardc

  1. Hi

    We applied this fix to our local version of Jasper Server Community Edition:
    (It corrects the naming issue and also allows direct opening or saving of the pdf rather than opening in a browser window.


    In ReportPdfExporter.java, setAdditionalResponseHeaders()


    remove:

    response.setHeader("Content-Disposition", "inline; filename=\"" + getFilename(context, "pdf") + "\"");


    replace with:

    // allow the download dialog box to open:
    response.setHeader("Content-Disposition", "attachment; filename=\"" + getFilename(context, "pdf") + "\"");

    // fix for opening PDF in IE6:
    response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");

     

    In view-report.js, exportReport()

    comment out or remove these lines so that a blank html window doesn't open:

    setBlankFormTarget();
    setTimeout('setSelfFormTarget()', 500);

     

     

  2. I noticed that grouping is missing in netbeans:

    1. in classic, you can select items that you want to group,  right click and then select 'Group selected element(s)'

    2. if you add elementGroup tags in the code and then go to Report Inspector, the label 'Element group' is missing next to document structure item

     

  3. Hi Sherman,

    I have 2 reports on JasperServer (Community edition) which both use the same query - one is a summary report and it has drill down 'report execution' hyperlinks to the other report which is a detail report. The detail report also has links back to the summary report.

    Rather than execute the query everytime a link is clicked (which effectively loads/re-loads the linked report), is there any way that I can pass the cached query results from one report to the other? Perhaps via a report scriptlet?

    Regards,

    Richard

  4. Here is the source: - class path is not included until after the method verifyDesign is callled

    Class: net.sf.jasperreports.engine.design.JRAbstractCompiler

    method: compileReport:
     

    public final JasperReport compileReport(JasperDesign jasperDesign) throws JRException	{		// check if the language is supported by the compiler		checkLanguage(jasperDesign.getLanguage());				// collect all report expressions		JRExpressionCollector expressionCollector = JRExpressionCollector.collector(jasperDesign);				// verify the report design		verifyDesign(jasperDesign, expressionCollector);		String nameSuffix = createNameSuffix();				// check if saving source files is required		boolean isKeepJavaFile = JRProperties.getBooleanProperty(JRProperties.COMPILER_KEEP_JAVA_FILE);		File tempDirFile = null;		if (isKeepJavaFile || needsSourceFiles)		{			String tempDirStr = JRProperties.getProperty(JRProperties.COMPILER_TEMP_DIR);			tempDirFile = new File(tempDirStr);			if (!tempDirFile.exists() || !tempDirFile.isDirectory())			{				throw new JRException("Temporary directory not found : " + tempDirStr);			}		}		List datasets = jasperDesign.getDatasetsList();		List crosstabs = jasperDesign.getCrosstabs();				JRCompilationUnit[] units = new JRCompilationUnit[datasets.size() + crosstabs.size() + 1];				// generating source code for the main report dataset		units[0] = createCompileUnit(jasperDesign, jasperDesign.getMainDesignDataset(), expressionCollector, tempDirFile, nameSuffix);		int sourcesCount = 1;		for (Iterator it = datasets.iterator(); it.hasNext(); ++sourcesCount)		{			JRDesignDataset dataset = (JRDesignDataset) it.next();			// generating source code for a sub dataset			units[sourcesCount] = createCompileUnit(jasperDesign, dataset, expressionCollector, tempDirFile, nameSuffix);		}				for (Iterator it = crosstabs.iterator(); it.hasNext(); ++sourcesCount)		{			JRDesignCrosstab crosstab = (JRDesignCrosstab) it.next();			// generating source code for a sub dataset			units[sourcesCount] = createCompileUnit(jasperDesign, crosstab, expressionCollector, tempDirFile, nameSuffix);		}				String classpath = JRProperties.getProperty(JRProperties.COMPILER_CLASSPATH);				try		{			// compiling generated sources			String compileErrors = compileUnits(units, classpath, tempDirFile);			if (compileErrors != null)			{				throw new JRException("Errors were encountered when compiling report expressions class file:n" + compileErrors);			}			// creating the report compile data			JRReportCompileData reportCompileData = new JRReportCompileData();			reportCompileData.setMainDatasetCompileData(units[0].getCompileData());						for (ListIterator it = datasets.listIterator(); it.hasNext();)			{				JRDesignDataset dataset = (JRDesignDataset) it.next();				reportCompileData.setDatasetCompileData(dataset, units[it.nextIndex()].getCompileData());			}						for (ListIterator it = crosstabs.listIterator(); it.hasNext();)			{				JRDesignCrosstab crosstab = (JRDesignCrosstab) it.next();				Integer crosstabId = expressionCollector.getCrosstabId(crosstab);				reportCompileData.setCrosstabCompileData(crosstabId.intValue(), units[datasets.size() + it.nextIndex()].getCompileData());			}			// creating the report			JasperReport jasperReport = 				new JasperReport(					jasperDesign,					getCompilerClass(),					reportCompileData,					expressionCollector,					nameSuffix					);						return jasperReport;		}		catch (JRException e)		{			throw e;		}		catch (Exception e)		{			throw new JRException("Error compiling report design.", e);		}		finally		{			if (needsSourceFiles && !isKeepJavaFile)			{				deleteSourceFiles(units);			}		}	}

     

  5. Hi,

    I am trying to compile a report using JasperCompileManager.compileReport(...). As I use my own classes I have to set the classpath using: JRProperties.setProperty(JRProperties.COMPILER_CLASSPATH, "..."). This seems to work ok as long as I have the classes in the WEB-INF/lib directory. However, if I have a class outside of WEB-INF/lib and add it to the classpath using JRProperties.setProperty(JRProperties.COMPILER_CLASSPATH, "..."), I get the following exception:


    net.sf.jasperreports.engine.design.JRValidationException: Report design not valid :
    1. java.lang.ClassNotFoundException: com.verticali.vap.reporting.scriptlets.ReportScriptletUtils
    at net.sf.jasperreports.engine.design.JRAbstractCompiler.verifyDesign(JRAbstractCompiler.java:260)
    at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:144)
    at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:220)
    at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:206)
     

    This looks like the same bug as reported in:

    http://jasperforge.org/plugins/espforum/view.php?group_id=102&forumid=103&topicid=18750

    In that bug, Andrey Shuvikov wrote: "Looking in the code I noticed that JRAbstractCompiler calls verifyDesign() _before_ dealing with classpath. But JRVerifier tries to load classes to verify their type, and classpath is not yet set at this point. Is it a bug or did I misunderstood the code?"

    There is mention of a patch in that bug and I also found a related patch: http://jasperforge.org/tracker/index.php?func=detail&aid=246&group_id=102&atid=369&action=edit

    I tried using the latest version of jasper reports: jasperreports-3.0.0-javaflow.jar, but this did not fix the problem.

    Is there a patch available to fix this?

    Regards,

    Richard

  6. Hi,

     

    I noticed that the file expressions.xml, which used to contain the formulas used in iReport is no longer in the user home > .ireport directory for iReport 2.0.2.

     

    I would like to modify the file with methods that I have in the Report Scriptlet class so that they can become available to use in iReport.

     

    Can you please let me know where the formulas are now being stored?

  7. Hi,

     

    I noticed that the file expressions.xml, which used to contain the formulas used in iReport is no longer in the user home > .ireport directory for iReport 2.0.2.

     

    I would like to modify the file with methods that I have in the Report Scriptlet class so that they can become available to use in iReport.

     

    Can you please let me know where the formulas are now being stored?

     

     

    Sorry this was meant to go into the iReport forum - I'll post it there

    Post edited by: richardc, at: 2007/11/27 14:54

  8. Hi,

     

    This is a duplicate of a previous entry:

    see

    http://www.jasperforge.org/index.php?option=com_joomlaboard&Itemid=&func=view&catid=8&id=28509#28509)

     

     

     

    Basically, the rows in Excel don't stretch enough to display all of the text in cells when exporting reports to Excel. It works ok when there is no text overflow, but when there is text overflow, only a proportion of the text is visible in excel.

     

    Is there a way to add Excel macro detail in a report template to get the spreadsheet to auto-fit the text?

     

    Currently users need to manually auto fit text in Excel by: selecting the rows in excel and then from the menu: Format->Row->AutoFit. However, using this can cause the page height to extend beyond the printable height for the page.

     

     

    Regards,

     

    Richard

     

    Post edited by: richardc, at: 2007/10/03 15:28

    Post edited by: richardc, at: 2007/11/26 08:13

  9. Hi,

     

    Is there anyway to do the following:

     

    (1) Styles

    Is it possible to have a single styles file which would be included included in the main report and all associated subreports?

    This would be very useful as I have a complex report with several subreports and have had to copy and paste the styles into every template.

     

    (2) Includes

    Is it possible to include sections of code into the templates? I have several subreports which have similar code and only differ by filter expression, heading text and color, so again this would be very useful here.

     

    Please let me know if any of the above are possible or are in the pipeline.

  10. Hi,

     

    I have a main report consisting of dynamic text fields which are required to stretch when the data overflows. This works fine for fields which belong to the main report. However, I also have variables which are returned from a subreport to the main report - when I display these as dynamic text fields, they do not stretch.

     

    Is this because the stretch positioning is determined before any subreport values are returned? If yes, is there any way to make the stretching be evaluated later, i.e. after the values have been returned from the subreport?

  11. Ok, so no replies to this post so far, but in the meantime I have discovered that there is a file in userhome >.ireport called expressions.xml.

     

    I can add all of my ReportScriptlet methods to the expressions.xml file and then they become available in the formulas list when using iReport.

     

    Note: you need to restart iReport after updating expressions.xml

    Post edited by: richardc, at: 2007/07/31 12:04

  12. Hi,

     

    I would like to import a text file containing a list of methods into the formulas list of iReport.

     

    However, when I import several methods, they are all listed on a single line in the formulas window.

     

    How can I add a new line character to separate each method?

     

    For more detail:

     

    I have a text file called ReportScriptletMethods.txt which contains methods such as:

     

    $P{REPORT_SCRIPTLET}.getCurrentYear()

    $P{REPORT_SCRIPTLET}.getCurrentMonth()

    $P{REPORT_SCRIPTLET}.getCurrentDay()

     

    I go to: Options > Formulas, click the 'New' Button, and then click the 'Import' Button and then navigate to my file 'ReportScriptletMethods.txt' file and then click 'Apply' and save.

     

    However, all of the methods are saved to a single line in the formulas window.

    Then, if I work on a variable expression and open the formulas window and select one of the imported methods, the entire list of imported methods gets selected.

     

    Is there a special new line character that I can use to separate the methods in my import list?

     

    Thank you.

     

    Cheers,

     

    Richard

  13. Hi Teodor,

     

    Here's more detail and findings.

     

    From some searching on google:

     

    Most browsers can't print partially transparent PNG images. (ref: http://www.econym.demon.co.uk/googlemaps/custom.htm)

     

    Firefox 1,0 won't print any PNG files that have transparency (ref: http://groups.google.com/group/Google-Maps-API/browse_thread/thread/c06c9736455921b3)

     

    Need to find out if either of the following are possible:

     

    (1) how to render the entire chart - particularly the surrounding chart axis areas without any transparent regions at all

     

    or

     

    (2) how to render the chart as a gif instead of png in Firefox

     

     

    I am using Firefox version 1.5.0.11

     

    Here is more complete code that I am using:

     

    Code:
    public abstract class Chart
    {
    protected JasperDesign design = null;
    protected JRDesignBand band = null;
    protected JRChartDataset dataset = null;
    protected JRDesignChart chart = null;
    private int pageHeight = 577;
    private int pageWidth = 630;
    private int chartHeight = pageHeight;

    public Chart(byte chartType, boolean small)
    throws JRException
    {
    if(small) {
    pageHeight = 385;
    pageWidth = 420;
    chartHeight = pageHeight;
    }

    design = new JasperDesign();
    design.setName("DataSourceReport");
    design.setLanguage("java");
    design.setPageWidth(pageWidth);
    design.setPageHeight(pageHeight);
    design.setColumnWidth(pageWidth);
    design.setLeftMargin(0);
    design.setRightMargin(0);
    design.setBottomMargin(0);
    design.setTopMargin(0);

    JRDesignField name = new JRDesignField();
    name.setName("OID");
    name.setValueClass(String.class);
    design.addField(name);

    band = new JRDesignBand();
    band.setHeight(pageHeight);
    design.setTitle(band);

    chart = new JRDesignChart(null, chartType);
    chart.setEvaluationTime(JRExpression.EVALUATION_TIME_REPORT);
    chart.setPositionType(JRDesignChart.POSITION_TYPE_FIX_RELATIVE_TO_TOP);
    chart.setX(0);
    chart.setY(0);
    chart.setWidth(pageWidth);
    chart.setHeight(chartHeight);
    chart.setBorder(JRGraphicElement.PEN_THIN);
    chart.setBorderColor(Color.BLACK);
    chart.setBackcolor(Color.WHITE);
    chart.setForecolor(Color.BLACK);

    chart.getPlot().setLabelRotation(30);

    chart.getPlot().setBackcolor(Color.WHITE);
    chart.getPlot().setBackgroundAlpha(1.0f);
    chart.setShowLegend(!small);

    band.addElement(chart);
    }

    public void add(Object o)
    throws JRException
    {
    if(JRDesignVariable.class.isInstance(o)) {
    design.addVariable((JRDesignVariable)o);
    } else if(JRDesignGroup.class.isInstance(o)) {
    design.addGroup((JRDesignGroup)o);
    } else if(JRDesignField.class.isInstance(o)) {
    design.addField((JRDesignField)o);
    } else {
    throw new JRException("This type of object is not supported with this method.");
    }
    }

    public void compile(ByteArrayOutputStream stream)
    throws JRException
    {
    JRProperties.setProperty(JRProperties.COMPILER_CLASSPATH, "lib/core/jasperreports-1.3.0.jar");
    JasperCompileManager.compileReportToStream(design, stream);
    }

    public String getXML()
    throws JRException
    {
    JRProperties.setProperty(JRProperties.COMPILER_CLASSPATH, "lib/core/jasperreports-1.3.0.jar");

    return JasperCompileManager.writeReportToXml(JasperCompileManager.compileReport(design));
    }
    }

     

    and

     

    Code:
    [code]public static ArrayList displayCharts(Collection dashboards, HttpServletRequest request,
    boolean small)
    throws Exception, IOException, NoSuchClassDOMetaException, JRException
    {
    if(dashboards==null) {
    throw new Exception("displayCharts() received a null as a collection");
    }

    if(dashboards.size()==0) {
    throw new Exception("displayCharts() received an empty collection");
    }

    // Create and populate list of JasperPrint objects
    ArrayList listOfPrints = new ArrayList(4);
    JasperPrint emptyPrint = new JasperPrint();

    Iterator dashboardsIterator = dashboards.iterator();

    while(dashboardsIterator.hasNext()) {
    DashboardChart dashboardChart = (DashboardChart)dashboardsIterator.next();
    int index = dashboardChart.getPosition().intValue()-1;

    // For single view index should always be 0
    if(dashboards.size()==1) {
    index = 0;
    }

    if(dashboardChart.getTemplate()==null) {
    listOfPrints.add(index, emptyPrint);
    } else {
    IData data = null;

    if(small) {
    data = dashboardChart.getTemplateSmall();
    } else {
    data = dashboardChart.getTemplate();
    }

    listOfPrints.add(index,
    JasperFillManager.fillReport(data.getBinaryStream(),
    new HashMap(),
    Utils.createDataSource(dashboardChart)));
    }
    }

    // Process list of print objects into charts
    StringBuffer sbuffer = new StringBuffer();

    request.getSession().setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_LIST_SESSION_ATTRIBUTE,
    listOfPrints);

    JRHtmlExporter exporter = new JRHtmlExporter();
    exporter.setParameter(JRHtmlExporterParameter.JASPER_PRINT_LIST, listOfPrints);
    exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI,
    request.getContextPath()+"/ctx/auth/dashboardimage?image=");
    exporter.setParameter(JRHtmlExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.TRUE);
    exporter.setParameter(JRHtmlExporterParameter.HTML_HEADER, "");
    exporter.setParameter(JRHtmlExporterParameter.BETWEEN_PAGES_HTML, DELIMETER);
    exporter.setParameter(JRHtmlExporterParameter.HTML_FOOTER, "");
    exporter.setParameter(JRExporterParameter.OUTPUT_STRING_BUFFER, sbuffer);
    exporter.exportReport();

    // Divide output by charts
    ArrayList outCharts = new ArrayList(4);
    String outString = sbuffer.toString();

    StringTokenizer charts = new StringTokenizer(outString, DELIMETER);
    dashboardsIterator = dashboards.iterator();

    while(dashboardsIterator.hasNext()) {
    DashboardChart dashboardChart = (DashboardChart)dashboardsIterator.next();
    int index = dashboardChart.getPosition().intValue()-1;

    // For single view index should always be 0
    if(dashboards.size()==1) {
    index = 0;
    }

    if(dashboardChart.getTemplate()==null) {
    outCharts.add(index, "Please setup this chart");
    } else if(((JasperPrint)listOfPrints.get(index)).getPages().size()==0) {
    outCharts.add(index, "There is no data in the system to run this report on.");
    } else {
    if(!charts.hasMoreTokens()) {
    throw new Exception("Charts ran out faster then needed.");
    }

    outCharts.add(index,
    charts.nextToken());
    }
    }

    return outCharts;
    }

    Post edited by: richardc, at: 2007/05/23 02:07

  14. Hi Teodor,

     

    Thank you for looking into this issue.

     

    For me also, the Firefox Print Preview looks ok - with no black background regions. The issue of black backgrounds actually occurs after pressing 'Print' in Firefox: the page prints with black background regions around the charts and similarly my printer's 'print preview' window displays the black backround regions.

     

    Would it be possible for you to test printing out the sample pie chart you referred to using the Firefox print button?

     

    Thanks again.

  15. I have jfreecharts which are displayed in HTML and can be printed via the browser's print button.

     

    The problem is in Mozilla Firefox, when a chart is printed, the key area below the chart prints with a black background. Please see the attached screenshot.

     

    I have the following code snippets below (shown in red font) which make the main part of the report background print as white in Firefox. Is there someway to specify that the key area should be white also?

     

    JRDesignChart chart = new JRDesignChart(null, chartType);

    chart.setBackcolor(Color.WHITE);

    ...

     

    JRHtmlExporter exporter = new JRHtmlExporter();

    exporter.setParameter(JRHtmlExporterParameter.JASPER_PRINT_LIST, listOfPrints);

    exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, request.getContextPath()+"/ctx/auth/dashboardimage?image=");

    exporter.setParameter(JRHtmlExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.TRUE);

    ...

     

    [file name=chart_print_preview_from_firefox.jpg size=44100]http://www.jasperforge.org/components/com_joomlaboard/uploaded/files/chart_print_preview_from_firefox.jpg[/file]

     

     

    I also tried:

    chart.getPlot().setBackcolor(Color.WHITE);

    chart.getPlot().setBackgroundAlpha(1.0f);

     

    But still no luck when printing from Firefox!

    The area's outside the plots are still black, so for bar charts, the axis detail can't be seen in the print; for pie charts, the key area under the chart can't be seen in the print.

     

    One thing I noticed: in IE browser, the chart image is rendered as a bitmap (this prints ok) - in the Firefox browser, the chart image is rendered as a .png image with transparent regions to the left and underneath chart area - these print as black regions.

     

    Any ideas anyone? Teodor?

    Post edited by: richardc, at: 2007/05/11 15:04

  16. How can I implement a dialog window for users to be prompted to enter in data before a report is run?

     

    I have the following code snippets:

     

    (1) java code for the parameter(s):

    Code:
    Map map = new HashMap();
    map.put("START_DATE", new Date());
    ...

     

    (2) parameters in template:

     

    Code:
    [code]<parameter name="START_DATE" isForPrompting="true" class="java.util.Date" >
    <parameterDescription><![CDATA["Please enter a Start Date (mm/dd/yyyy)"]]></parameterDescription>
    </parameter>

     

    When I run the report, no dialog window appears. Can you please give details on how to implement a simple dialog window for this?

×
×
  • Create New...