• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java LocalJasperReportsContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中net.sf.jasperreports.engine.util.LocalJasperReportsContext的典型用法代码示例。如果您正苦于以下问题:Java LocalJasperReportsContext类的具体用法?Java LocalJasperReportsContext怎么用?Java LocalJasperReportsContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



LocalJasperReportsContext类属于net.sf.jasperreports.engine.util包,在下文中一共展示了LocalJasperReportsContext类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: LocalJasperReportsContext

import net.sf.jasperreports.engine.util.LocalJasperReportsContext; //导入依赖的package包/类
@Override
public void	contextInitialized(ServletContextEvent ce) 
{
	LocalJasperReportsContext localJasperReportsContext = new LocalJasperReportsContext(DefaultJasperReportsContext.getInstance());
	SimpleFileResolver fileResolver = 
		new SimpleFileResolver(
			new File(
				new File(ce.getServletContext().getRealPath("/")), 
				ce.getServletContext().getInitParameter("net.sf.jasperreports.web.file.repository.root")
				)
			);
	localJasperReportsContext.setFileResolver(fileResolver);
	
	AbstractServlet.setJasperReportsContext(localJasperReportsContext);
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:16,代码来源:JasperReportsContextListener.java


示例2: ensureJasperReportsContext

import net.sf.jasperreports.engine.util.LocalJasperReportsContext; //导入依赖的package包/类
/**
 *
 */
@SuppressWarnings("deprecation")
protected void ensureJasperReportsContext()
{
	if (
		parameters.containsKey(JRExporterParameter.CLASS_LOADER)
		|| parameters.containsKey(JRExporterParameter.URL_HANDLER_FACTORY)
		|| parameters.containsKey(JRExporterParameter.FILE_RESOLVER)
		)
	{
		LocalJasperReportsContext localJasperReportsContext = new LocalJasperReportsContext(jasperReportsContext);

		if (parameters.containsKey(JRExporterParameter.CLASS_LOADER))
		{
			localJasperReportsContext.setClassLoader((ClassLoader)parameters.get(JRExporterParameter.CLASS_LOADER));
		}

		if (parameters.containsKey(JRExporterParameter.URL_HANDLER_FACTORY))
		{
			localJasperReportsContext.setURLStreamHandlerFactory((URLStreamHandlerFactory)parameters.get(JRExporterParameter.URL_HANDLER_FACTORY));
		}

		if (parameters.containsKey(JRExporterParameter.FILE_RESOLVER))
		{
			localJasperReportsContext.setFileResolver((FileResolver)parameters.get(JRExporterParameter.FILE_RESOLVER));
		}
		
		setJasperReportsContext(localJasperReportsContext);
	}
	
	FontUtil.getInstance(jasperReportsContext).resetThreadMissingFontsCache();
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:35,代码来源:JRAbstractExporter.java


示例3: getLocalJasperReportsContext

import net.sf.jasperreports.engine.util.LocalJasperReportsContext; //导入依赖的package包/类
/**
 * 
 */
protected JasperReportsContext getLocalJasperReportsContext(File file)
{
	SimpleFileResolver fileResolver =
		new SimpleFileResolver(
			Arrays.asList(new File[]{file.getParentFile(), new File(".")})
			);
	fileResolver.setResolveAbsolutePath(true);
	
	LocalJasperReportsContext localJasperReportsContext = new LocalJasperReportsContext(jasperReportsContext);
	localJasperReportsContext.setFileResolver(fileResolver);
	return localJasperReportsContext;
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:16,代码来源:JasperFillManager.java


示例4: setParametersToContext

import net.sf.jasperreports.engine.util.LocalJasperReportsContext; //导入依赖的package包/类
protected final void setParametersToContext(Map<String,Object> parameterValues)
{
	JasperReportsContext localContext = LocalJasperReportsContext.getLocalContext(jasperReportsContext, parameterValues);
	if (localContext != jasperReportsContext)
	{
		setJasperReportsContext(localContext);
	}
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:9,代码来源:BaseReportFiller.java


示例5: evaluateParameterDefaultValues

import net.sf.jasperreports.engine.util.LocalJasperReportsContext; //导入依赖的package包/类
/**
 * Evaluates the default values for the parameters of a report.
 * 
 * @param report the report
 * @param initialParameters initial parameter value map
 * @return a map containing parameter values indexed by parameter names
 * @throws JRException
 */
public static Map<String,Object> evaluateParameterDefaultValues(JasperReportsContext jasperReportsContext, JasperReport report, Map<String,Object> initialParameters) throws JRException
{
	Map<String,Object> valuesMap = initialParameters == null ? new HashMap<String,Object>() : new HashMap<String,Object>(initialParameters);
	
	valuesMap.put(JRParameter.JASPER_REPORT, report);
	
	ObjectFactory factory = new ObjectFactory();
	JRDataset reportDataset = report.getMainDataset();
	JRFillDataset fillDataset = factory.getDataset(reportDataset);
	
	fillDataset.setJasperReportsContext(LocalJasperReportsContext.getLocalContext(jasperReportsContext, initialParameters));
	
	fillDataset.createCalculator(report);
	fillDataset.initCalculator();

	JRResourcesFillUtil.ResourcesFillContext resourcesContext = 
		JRResourcesFillUtil.setResourcesFillContext(valuesMap);
	try
	{
		fillDataset.setParameterValues(valuesMap);
		
		Map<String,Object> parameterValues = new HashMap<String,Object>();
		JRParameter[] parameters = reportDataset.getParameters();
		for (int i = 0; i < parameters.length; i++)
		{
			JRParameter param = parameters[i];
			if (!param.isSystemDefined())
			{
				String name = param.getName();
				Object value = fillDataset.getParameterValue(name);
				parameterValues.put(name, value);
			}
		}
		
		return parameterValues;
	}
	finally
	{
		fillDataset.disposeParameterContributors();
		JRResourcesFillUtil.revertResourcesFillContext(resourcesContext);
	}
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:51,代码来源:JRParameterDefaultValuesEvaluator.java


示例6: baseInit

import net.sf.jasperreports.engine.util.LocalJasperReportsContext; //导入依赖的package包/类
/**
 *
 */
private void baseInit() {
	JasperReportsContext localContext = LocalJasperReportsContext.getLocalContext(getJasperReportsContext(), parameterValues);
	if (localContext != getJasperReportsContext())
	{
		setJasperReportsContext(localContext);
	}
	//       fillingThread = Thread.currentThread();
	try
	{
		boundElements = new HashMap<JREvaluationTime, LinkedHashMap<PageKey, LinkedMap<Object, EvaluationBoundAction>>>();

		createBoundElementMaps(JREvaluationTime.EVALUATION_TIME_REPORT);
		createBoundElementMaps(JREvaluationTime.EVALUATION_TIME_PAGE);
		createBoundElementMaps(JREvaluationTime.EVALUATION_TIME_COLUMN);

		if (groups != null)
		{
			for (int i = 0; i < groups.length; i++)
			{
				createBoundElementMaps(JREvaluationTime.getGroupEvaluationTime(groups[i].getName()));
			}
		}

		for (Iterator<JRBand> i = bands.iterator(); i.hasNext();)
		{
			JRFillBand band = (JRFillBand) i.next();
			createBoundElementMaps(JREvaluationTime.getBandEvaluationTime(band));
		}

		if (parentFiller != null)
		{
			parentFiller.registerSubfiller(this);
		}

		setParameters(parameterValues);

		loadStyles();

		jasperPrint.setName(name);
		jasperPrint.setPageWidth(pageWidth);
		jasperPrint.setPageHeight(pageHeight);
		jasperPrint.setTopMargin(topMargin);
		jasperPrint.setLeftMargin(leftMargin);
		jasperPrint.setBottomMargin(bottomMargin);
		jasperPrint.setRightMargin(rightMargin);
		jasperPrint.setOrientation(orientation);

		jasperPrint.setFormatFactoryClass(jasperReport.getFormatFactoryClass());
		jasperPrint.setLocaleCode(JRDataUtils.getLocaleCode(getLocale()));
		jasperPrint.setTimeZoneId(JRDataUtils.getTimeZoneId(getTimeZone()));

		jasperPrint.setDefaultStyle(defaultStyle);

		/*   */
		if (styles != null && styles.length > 0)
		{
			for (int i = 0; i < styles.length; i++)
			{
				addPrintStyle(styles[i]);
			}
		}

		/*   */
		//Done in write(List<T>) mainDataset.start();
	} catch (Exception e) {
		logger.error("Unable to initialise report", e);
	}

}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:73,代码来源:JRVerticalReportWriter.java


示例7: deriveContext

import net.sf.jasperreports.engine.util.LocalJasperReportsContext; //导入依赖的package包/类
static public SimpleJasperReportsContext deriveContext()
{
    SimpleJasperReportsContext co = new LocalJasperReportsContext(getInstance());
    return co;
}
 
开发者ID:JockiHendry,项目名称:ireport-fork,代码行数:6,代码来源:IRLocalJasperReportsContext.java


示例8: fillReport

import net.sf.jasperreports.engine.util.LocalJasperReportsContext; //导入依赖的package包/类
public static JasperPrint fillReport(StorageService storageService, String key, JasperReport jasper, Map<String, Object> params, Connection conn) throws JRException, InterruptedException {
    	Settings settings = storageService.getSettings();
        params.put(JRParameter.REPORT_FILE_RESOLVER, new SimpleFileResolver(new File(settings.getJasper().getHome())));

        // process stopped before runner starts
        if (JasperRunnerFactory.containsRunner(key)) {
            JasperRunnerFactory.removeRunner(key);
            ConnectionUtil.closeConnection(conn);
            return null;
        }

//        System.out.println("------------------------------");
//        for (String s : params.keySet()) {
//            System.out.println("  -> param="+s + " ["  + params.get(s)  + "]");
//        }
//        System.out.println("------------------------------");

        // Jasper 5.1.0+
        if (ctx == null) {
        	LocalJasperReportsContext localContext = new LocalJasperReportsContext(DefaultJasperReportsContext.getInstance());
        	localContext.setClassLoader(JasperReportsUtil.class.getClassLoader());
        	localContext.setFileResolver(new SimpleFileResolver(new File(settings.getJasper().getHome())));
        	ctx = localContext;
        }
        final JasperAsynchronousFillHandle handle = new JasperAsynchronousFillHandle(ctx, jasper, params, conn);
//        final JasperAsynchronousFillHandle handle = new JasperAsynchronousFillHandle(jasper, params, conn);
        JasperPrint print = null;
        try {
            JasperRunnerFactory.addRunner(key, handle);
            //Start the asynchronous thread to fill the report
            handle.startFill();
            //Wait until the thread ends to get the result
            handle.getFillThread().join();

            if (!handle.isCancelled()) {
                print = handle.getJasperPrint();
            } else {
                throw new InterruptedException("Running process was interrupted.");
            }
        } catch (InterruptedException ie) {
            throw ie;
        } catch (Exception e) {
            throw new JRException(e.getMessage());
        } finally {
            JasperRunnerFactory.removeRunner(key);
        }
        return print;
    }
 
开发者ID:nextreports,项目名称:nextreports-server,代码行数:49,代码来源:JasperReportsUtil.java



注:本文中的net.sf.jasperreports.engine.util.LocalJasperReportsContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SortMeta类代码示例发布时间:2022-05-22
下一篇:
Java XMLReaderJDOMFactory类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap