Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » How can i integrate jasper reports on scout?
icon3.gif  How can i integrate jasper reports on scout? [message #1755991] Thu, 09 March 2017 19:51 Go to next message
marco santos is currently offline marco santosFriend
Messages: 9
Registered: March 2017
Junior Member
Hi everyone,
I am a newcomer here and i'm looking for a tutorial of how to integrate jasper reports in scout.
I use the eclipse neon and i don't have the "scout explorer view" only the "project explorer"
the integration tutorial: https://wiki.eclipse.org/Scout/Tutorial/4.0/JasperReports_Integration
show how to do it but using "scout explorer view" so i am a little lost, someone knows how to do it on eclipse neon on "project explorer" ?

Re: How can i integrate jasper reports on scout? [message #1758013 is a reply to message #1755991] Wed, 22 March 2017 18:25 Go to previous messageGo to next message
Andreas Hoegger is currently offline Andreas HoeggerFriend
Messages: 185
Registered: February 2010
Senior Member
Jasper integration:
The integration is basically the same as in any other java/maven environment (lots of tuturials around).



  1. pom dependencies
    Add the following dependencies to your project. Usually in the server parts pom file.
    		<dependency>
    			<groupId>net.sf.jasperreports</groupId>
    			<artifactId>jasperreports</artifactId>
    			<version>6.4.0</version>
    			<exclusions>
    				<exclusion>
    					<groupId>javax.xml.stream</groupId>
    					<artifactId>stax-api</artifactId>
    					<!-- <version>1.0-2</version> -->
    				</exclusion>
    				<exclusion>
    					<groupId>org.bouncycastle</groupId>
    					<artifactId>bcmail-jdk14</artifactId>
    				</exclusion>
    				<exclusion>
    					<groupId>org.bouncycastle</groupId>
    					<artifactId>bcprov-jdk14</artifactId>
    				</exclusion>
    			</exclusions>
    		</dependency>
    		<dependency>
    			<groupId>net.sf.jasperreports</groupId>
    			<artifactId>jasperreports-fonts</artifactId>
    			<version>6.0.0</version>
    		</dependency>
    

  2. Report definition
    Create a report definition (*.jrxml) e.g. using the report designer and put it into the <your module>/src/main/resources/jasper.
  3. Create the report
    Could look like:
        InputStream billStream = getClass().getResourceAsStream("/jasper/bill.jrxml");
    
        try {
          JasperReport jasperBillReport = JasperCompileManager.compileReport(billStream);
          Map<String, Object> parameters = new HashMap<>();
    	  // put parameters here
          JRBeanCollectionDataSource connection = new JRBeanCollectionDataSource(CollectionUtility.arrayList(yourBean));
          JasperPrint print = JasperFillManager.fillReport(jasperBillReport, parameters, connection);
          return JasperExportManager.exportReportToPdf(print);
        }
        catch (JRException e) {
          throw BEANS.get(PlatformExceptionTranslator.class).translate(e);
        }
    



A sample implementation is available under Github Docbox.

-andreas
Re: How can i integrate jasper reports on scout? [message #1758897 is a reply to message #1758013] Tue, 04 April 2017 09:55 Go to previous messageGo to next message
marco giudici is currently offline marco giudiciFriend
Messages: 184
Registered: February 2013
Location: Italy
Senior Member
Hi Andreas,
in your example you create a Jasper Reports in PDF
return JasperExportManager.exportReportToPdf(print);

Is it possible generate a word document? If so, how?

You have examples or suggestions on how to proceed

Thanks
Marco
Re: How can i integrate jasper reports on scout? [message #1759956 is a reply to message #1758897] Thu, 20 April 2017 13:21 Go to previous message
marco santos is currently offline marco santosFriend
Messages: 9
Registered: March 2017
Junior Member
Hello Andreas,
Thank you for the helpful tips including the sample implementation.
I changed many things in my implementation but i successfully generated a jasper report and save it on database using a bytea field on postgres, i am having only a problem to retreive it and show on the browser

this the File field on my TablePage that i am using to retreive the content(pdf file)
public class FileColumn extends AbstractColumn<byte[]> {
			
			@Override
			protected String getConfiguredHeaderText() {
				return TEXTS.get("File");
			}
			
			@Override
			protected boolean getConfiguredHtmlEnabled() {
				return true;
			}

			@Override
			protected int getConfiguredWidth() {
				return 100;
			}

			@Override
			protected boolean getConfiguredVisible() {
				return true;
			}

			@Override
		      protected void execDecorateCell(Cell cell, ITableRow row) {
		     		        
		        StringBuilder linkBuilder = new StringBuilder();
		        linkBuilder.append(getFileColumn ().getValue(row));
		        String encodedHtml = HTML.link(linkBuilder, TEXTS.get("Open")).addAttribute("target", "_blank").toHtml();
		        cell.setHtmlEnabled(true);
		        cell.setText(encodedHtml);
		      }
		}


Any ideia of how can i do it?



Thank you, Marco.



Previous Topic:[neon] Enable HTML Selectors for Selenium
Next Topic:[NEON] Table page with detail view
Goto Forum:
  


Current Time: Mon Dec 18 20:28:08 GMT 2017

Powered by FUDForum. Page generated in 0.02798 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software