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

nemanzini

Members
  • Posts

    2
  • 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

Everything posted by nemanzini

  1. Hi guys, I'm new at java and jasper. I have created reports using JasperReports and iReport but have to make my reports more dynamic. Users should be able to select columns that should appear on report. I have tried going thru the article- http://www.ibm.com/developerworks/websphere/library/techarticles/0505_olivieri/0505_olivieri.html but have an error that reads - identify expected at this line :- BufferedWriter writer = new BufferedWriter(new, OutputStreamWriter(outStream)); here is the complete code: import org.apache.velocity.Template; import org.apache.velocity.app.Velocity; import org.apache.velocity.context.Context; import org.apache.velocity.exception.ParseErrorException; import org.apache.velocity.exception.ResourceNotFoundException; import org.apache.velocity.servlet.VelocityServlet; import java.io.BufferedWriter; import java.io.PipedInputStream; import java.io.PipedOutputStream; import javax.servlet.ServletConfig; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.Properties; public class VelocityTest extends VelocityServlet { protected Properties loadConfiguration(ServletConfig config) { Properties properties = new Properties(); properties.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, config.getServletContext().getRealPath("/")); return properties; } public Template handleRequest(HttpServletRequest request, HttpServletResponse response, Context context) { context.put("sql","SELECT * from wcs.tblpayments"); String fieldList[] = {"PAYMENT_NO","WCS_NUMBER","CONTRACT_NO","PAYMENT_INDICATOR","DIVISION_CODE","BENEFICIARY_CODE"," ADVICE_NUMBER"}; context.put("title","testing Velocity"); context.put("$headerString","HEADER"); context.put("fieldList",fieldList); Template template = null; PipedInputStream inStream; BufferedWriter writer ; Thread thread; PipedOutputStream outStream; TemplateCompiler compiler; try { PipedOutputStream outStream = new PipedOutputStream(); BufferedWriter writer = new BufferedWriter(new, OutputStreamWriter(outStream)); // Connect input stream to output stream inStream = new PipedInputStream(outStream); compiler = new TemplateCompiler(inStream); thread = new Thread(compiler); thread.start(); template.merge(context, writer); template = getTemplate("BasicReport.vm"); // tpl = getTemplate("hello.vm"); } catch (ResourceNotFoundException e) { e.printStackTrace(); } catch (ParseErrorException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { if (writer != null) { writer.flush(); writer.close(); } } thread.join(); // Get compiled report return (compiler.getJasperReport()); } } any assistance will be greatly appreciated
  2. Hi guys, I'm new at java and jasper. I have created reports using JasperReports and iReport but have to make my reports more dynamic. Users should be able to select columns that should appear on report. I have tried going thru the article- http://www.ibm.com/developerworks/websphere/library/techarticles/0505_olivieri/0505_olivieri.html but have an error that reads - identify expected at this line :- BufferedWriter writer = new BufferedWriter(new, OutputStreamWriter(outStream)); here is the complete code: import org.apache.velocity.Template; import org.apache.velocity.app.Velocity; import org.apache.velocity.context.Context; import org.apache.velocity.exception.ParseErrorException; import org.apache.velocity.exception.ResourceNotFoundException; import org.apache.velocity.servlet.VelocityServlet; import java.io.BufferedWriter; import java.io.PipedInputStream; import java.io.PipedOutputStream; import javax.servlet.ServletConfig; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.Properties; public class VelocityTest extends VelocityServlet { protected Properties loadConfiguration(ServletConfig config) { Properties properties = new Properties(); properties.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, config.getServletContext().getRealPath("/")); return properties; } public Template handleRequest(HttpServletRequest request, HttpServletResponse response, Context context) { context.put("sql","SELECT * from wcs.tblpayments"); String fieldList[] = {"PAYMENT_NO","WCS_NUMBER","CONTRACT_NO","PAYMENT_INDICATOR","DIVISION_CODE","BENEFICIARY_CODE","ADVICE_NUMBER"}; context.put("title","testing Velocity"); context.put("$headerString","HEADER"); context.put("fieldList",fieldList); Template template = null; PipedInputStream inStream; BufferedWriter writer ; Thread thread; PipedOutputStream outStream; TemplateCompiler compiler; try { PipedOutputStream outStream = new PipedOutputStream(); BufferedWriter writer = new BufferedWriter(new, OutputStreamWriter(outStream)); // Connect input stream to output stream inStream = new PipedInputStream(outStream); compiler = new TemplateCompiler(inStream); thread = new Thread(compiler); thread.start(); template.merge(context, writer); tpl = getTemplate("BasicReport.vm"); // tpl = getTemplate("hello.vm"); } catch (ResourceNotFoundException e) { e.printStackTrace(); } catch (ParseErrorException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { if (writer != null) { writer.flush(); writer.close(); } } thread.join(); // Get compiled report return (compiler.getJasperReport()); } } any assistance will be greatly appreciated
×
×
  • Create New...