本文整理汇总了Java中fr.opensagres.xdocreport.template.IContext.put方法的典型用法代码示例。如果您正苦于以下问题:Java IContext.put方法的具体用法?Java IContext.put怎么用?Java IContext.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fr.opensagres.xdocreport.template.IContext
的用法示例。
在下文中一共展示了IContext.put方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: populateContext
import fr.opensagres.xdocreport.template.IContext; //导入方法依赖的package包/类
public void populateContext( IContext context, IXDocReport report, HttpServletRequest request )
{
String name = request.getParameter( "name" );
Project project = new Project( name );
context.put( "project", project );
int nbDevelopers = 0;
try
{
nbDevelopers = Integer.parseInt( request.getParameter( "nbDevelopers" ) );
}
catch ( Throwable e )
{
}
List<Developer> developers = new ArrayList<Developer>( nbDevelopers );
for ( int i = 0; i < nbDevelopers; i++ )
{
developers.add( new Developer( "Name" + i, "LastName" + i, "Mail" + i ) );
}
context.put( "developers", developers );
}
示例2: populateContext
import fr.opensagres.xdocreport.template.IContext; //导入方法依赖的package包/类
@Override
protected void populateContext( IContext context, String reportId, HttpServletRequest req )
throws XDocReportException
{
String project = req.getParameter( "project" );
context.put( "project", project );
String url = req.getParameter( "url" );
context.put( "url", url );
String comments_html = req.getParameter( "comments_html" );
context.put( "comments_html", comments_html );
String comments_gwiki = req.getParameter( "comments_gwiki" );
context.put( "comments_gwiki", comments_gwiki );
String comments_mediawiki = req.getParameter( "comments_mediawiki" );
context.put( "comments_mediawiki", comments_mediawiki );
}
示例3: populateContext
import fr.opensagres.xdocreport.template.IContext; //导入方法依赖的package包/类
@Override
protected void populateContext( IContext context, String reportId, HttpServletRequest request )
throws XDocReportException
{
if ( ODT_PROJECT_WITH_VELOCITY_LIST.equals( reportId ) || DOCX_PROJECT_WITH_VELOCITY_LIST.equals( reportId ) )
{
String name = request.getParameter( "name" );
Project project = new Project( name );
context.put( "project", project );
int nbDevelopers = 0;
try
{
nbDevelopers = Integer.parseInt( request.getParameter( "nbDevelopers" ) );
}
catch ( Throwable e )
{
}
List<Developer> developers = new ArrayList<Developer>( nbDevelopers );
for ( int i = 0; i < nbDevelopers; i++ )
{
developers.add( new Developer( "Name" + i, "LastName" + i, "Mail" + i ) );
}
context.put( "developers", developers );
}
else
{
throw new XDocReportNotFoundException( reportId );
}
}
示例4: populateContext
import fr.opensagres.xdocreport.template.IContext; //导入方法依赖的package包/类
@Override
protected void populateContext( IContext context, String reportId, HttpServletRequest req )
throws XDocReportException
{
if ( reportId.equals( ODT_HELLO_WORD_WITH_VELOCITY ) )
{
// reportId = ODTHelloWorldWithVelocity, prepare context with name
String name = req.getParameter( "name" );
context.put( "name", name );
}
else
{
throw new XDocReportNotFoundException( reportId );
}
}
示例5: populateContext
import fr.opensagres.xdocreport.template.IContext; //导入方法依赖的package包/类
@Override
public void populateContext( IContext context, HttpServletRequest request )
{
List<DynamicBean> dataModelList = new ArrayList<DynamicBean>();
for ( MetaDataModelSimpleField field : fields )
{
String name = field.getName();
String[] values = request.getParameterValues( name );
if ( values != null )
{
for ( int i = 0; i < values.length; i++ )
{
DynamicBean bean = null;
if ( dataModelList.size() >= i + 1 )
{
bean = dataModelList.get( i );
}
else
{
bean = new DynamicBean();
dataModelList.add( bean );
}
String value = values[i];
String key = name.substring( super.getName().length() + 1, name.length() );
bean.setValue( key.split( "[.]" ), value, 0 );
}
}
}
context.put( super.getName(), dataModelList );
}
示例6: populateContext
import fr.opensagres.xdocreport.template.IContext; //导入方法依赖的package包/类
public void populateContext( IContext context, HttpServletRequest request )
{
String value = request.getParameter( super.getName() );
if ( value != null )
{
context.put( super.getName(), value );
}
}
示例7: generateDocumentFromTemplate
import fr.opensagres.xdocreport.template.IContext; //导入方法依赖的package包/类
private static void generateDocumentFromTemplate(
TemplateModel templateModel, OutputStream out)
throws XDocReportException, IOException {
InputStream in = null;
try {
in = templateModel.getTemplateFile().getInputStream();
IXDocReport report = null;
if (TemplateType.VELOCITY.equals(templateModel.getTemplateType())) {
report = XDocReportRegistry.getRegistry().loadReport(in,
TemplateEngineKind.Velocity);
} else {
report = XDocReportRegistry.getRegistry().loadReport(in,
TemplateEngineKind.Freemarker);
}
IContext context = report.createContext();
context.put(templateModel.getInTemplateDesignation(), templateModel);
if (templateModel.getPostProcessor() != null) {
ByteArrayOutputStream tempOutputStream = new ByteArrayOutputStream();
report.process(context, tempOutputStream);
InputStream tempInputStream = new ByteArrayInputStream(
tempOutputStream.toByteArray());
ODSProcessor.transformODS(tempInputStream, out,
templateModel.getPostProcessor());
} else {
report.process(context, out);
}
} finally {
IOUtils.closeQuietly(in);
}
}
示例8: generateLettre
import fr.opensagres.xdocreport.template.IContext; //导入方法依赖的package包/类
/**
* @param templateLettre
* @param data
* @param fichierSignature
* @return l'inputstram de la lettre
*/
public InputStream generateLettre(final String templateLettre, final ExportLettreCandidat data,
final InputStream fichierSignature) {
InputStream template = MethodUtils.getXDocReportTemplate(templateLettre, i18nController.getLangueCandidat(),
cacheController.getLangueDefault().getCodLangue());
if (template == null) {
return null;
}
ByteArrayInOutStream out = new ByteArrayInOutStream();
try {
/* Ajout date et heure */
data.setDateHeure(formatterDateTime.format(LocalDateTime.now()));
data.setDate(formatterDate.format(LocalDateTime.now()));
/* Generation du template */
IXDocReport report = XDocReportRegistry.getRegistry().loadReport(template, TemplateEngineKind.Velocity);
/* Variables */
IContext context = report.createContext();
context.put("data", data);
/* Pour l'image */
FieldsMetadata metadata = new FieldsMetadata();
if (fichierSignature != null) {
metadata.addFieldAsImage("imageSignature");
IImageProvider originalSizeLogo = new ByteArrayImageProvider(fichierSignature, true);
context.put("imageSignature", originalSizeLogo);
} else {
/* Si pas de fichier, on supprime l'image */
metadata.addFieldAsImage("imageSignature", NullImageBehaviour.RemoveImageTemplate);
}
report.setFieldsMetadata(metadata);
/* On vérifie si on affiche le tableau de signataire */
if (data.getLibelleSignature().equals("") && fichierSignature == null) {
context.put("showSignataire", false);
} else {
context.put("showSignataire", true);
}
/* Transformation en pdf */
Options options = Options.getTo(ConverterTypeTo.PDF).via(ConverterTypeVia.XWPF);
report.convert(context, options, out);
return signaturePdfManager.signPdf(out);
} catch (Exception e) {
// probleme de taille de signature XDocConverterException + StackOverflowError
if (e.getClass() != null && e instanceof XDocConverterException && e.getCause() != null
&& e.getCause() instanceof StackOverflowError) {
Notification.show(applicationContext.getMessage("candidature.lettre.download.sign.error", null,
UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
} else {
Notification.show(applicationContext.getMessage("candidature.lettre.download.error", null,
UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
logger.error("erreur a la création de la lettre", e);
}
return null;
} finally {
// fermeture des fichiers
MethodUtils.closeRessource(fichierSignature);
MethodUtils.closeRessource(template);
MethodUtils.closeRessource(out);
}
}
示例9: populateContext
import fr.opensagres.xdocreport.template.IContext; //导入方法依赖的package包/类
public void populateContext( IContext context, IXDocReport report, HttpServletRequest request )
{
String name = request.getParameter( "name" );
context.put( "name", name );
}