If you like this tutorial it would be very nice, if you could click on some of the google ads you see on the right side. It helps me run this block and motivates me ;)
If you have any questions, feel free to leave a comment.
If you like this tutorial it would be very nice, if you could click on some of the google ads you see on the right side. It helps me run this block and motivates me ;)
If you like this post it would be very nice, if you could click on some of the google ads you see on the right side. It helps me run this block and motivates me ;)This is just a text
//get input stream to jasper file InputStream input = Thread.currentThread().getContextClassLoader() .getResourceAsStream("report1.jasper"); final FileBufferedOutputStream fbos = new FileBufferedOutputStream(); //load report JasperReport report = (JasperReport) JRLoader.loadObject(input); JasperPrint jasperPrint = JasperFillManager.fillReport(report, parameters, null); //export report as PDF JRExporter exporter = new net.sf.jasperreports.engine.export.JRPdfExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, fbos); exporter.exportReport(); //write pdf to servlet output stream ServletOutputStream ouputStream = response.getOutputStream(); response.setContentLength(fbos.size()); fbos.writeData(ouputStream); fbos.flush(); fbos.close(); fbos.dispose(); ouputStream.flush();
public static void startProcess(String name, String portletId) { SchedulerEntry schedulerEntry = new SchedulerEntryImpl(); schedulerEntry.setDescription("This is a programatically created process"); schedulerEntry.setEventListenerClass(Your-Listener-Class.class.getName()); schedulerEntry.setTimeUnit(TimeUnit.MINUTE); schedulerEntry.setTriggerType(TriggerType.SIMPLE); schedulerEntry.setTriggerValue(30); try { SchedulerPropertiesLocalServiceUtil.turnOnProcess(Your-Listener-Class.getName()); SchedulerEngineHelperUtil.schedule(schedulerEntry, StorageType.MEMORY_CLUSTERED, portletId, 0); } catch (SchedulerException e) { _log.warn(e); } }
try { scheduledJobs = SchedulerEngineHelperUtil.getScheduledJobs(); for (SchedulerResponse resp : scheduledJobs) { if (resp.getJobName().equalsIgnoreCase(name)) { String groupName = resp.getGroupName(); StorageType storageType = resp.getStorageType(); _log.info("Unscheduling :" + name); SchedulerEngineHelperUtil.unschedule(name, groupName, storageType); } } } catch (SchedulerException e) { _log.warn(e); }