use of org.olat.core.gui.render.velocity.VelocityRenderDecorator in project OpenOLAT by OpenOLAT.
the class ExportBinderAsCPResource method renderVelocityContainer.
private String renderVelocityContainer(VelocityContainer mainVC) {
StringOutput sb = new StringOutput(32000);
URLBuilder ubu = new URLBuilder("auth", "1", "0");
Renderer renderer = Renderer.getInstance(mainVC, translator, ubu, new RenderResult(), new EmptyGlobalSettings());
VelocityRenderDecorator vrdec = new VelocityRenderDecorator(renderer, mainVC, sb);
mainVC.contextPut("r", vrdec);
renderer.render(sb, mainVC, null);
return sb.toString();
}
use of org.olat.core.gui.render.velocity.VelocityRenderDecorator in project OpenOLAT by OpenOLAT.
the class ExportBinderAsPDFResource method createResultHTML.
private String createResultHTML(Component content) {
String pagePath = Util.getPackageVelocityRoot(this.getClass()) + "/export.html";
VelocityContainer mainVC = new VelocityContainer("html", pagePath, translator, null);
mainVC.put("cmp", content);
mainVC.contextPut("bodyCssClass", "o_portfolio_export");
StringOutput sb = new StringOutput(32000);
URLBuilder ubu = new URLBuilder("auth", "1", "0");
Renderer renderer = Renderer.getInstance(mainVC, translator, ubu, new RenderResult(), new EmptyGlobalSettings());
VelocityRenderDecorator vrdec = new VelocityRenderDecorator(renderer, mainVC, sb);
mainVC.contextPut("r", vrdec);
renderer.render(sb, mainVC, null);
return sb.toString();
}
use of org.olat.core.gui.render.velocity.VelocityRenderDecorator in project OpenOLAT by OpenOLAT.
the class VelocityContainerRenderer method render.
/**
* @see org.olat.core.gui.render.ui.ComponentRenderer#render(org.olat.core.gui.render.Renderer,
* org.olat.core.gui.render.StringOutput, org.olat.core.gui.components.Component,
* org.olat.core.gui.render.URLBuilder, org.olat.core.gui.translator.Translator,
* org.olat.core.gui.render.RenderResult, java.lang.String[])
*/
@Override
public void render(Renderer renderer, StringOutput target, Component source, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
VelocityContainer vc = (VelocityContainer) source;
String pagePath = vc.getPage();
Context ctx = vc.getContext();
// the component id of the urlbuilder will be overwritten by the recursive render call for
// subcomponents (see Renderer)
Renderer fr = Renderer.getInstance(vc, translator, ubu, renderResult, renderer.getGlobalSettings());
VelocityRenderDecorator vrdec = new VelocityRenderDecorator(fr, vc, target);
ctx.put("r", vrdec);
VelocityHelper vh = VelocityHelper.getInstance();
vh.mergeContent(pagePath, ctx, target, null);
// free the decorator
ctx.remove("r");
IOUtils.closeQuietly(vrdec);
// set all not rendered component as not dirty
for (Component cmp : vc.getComponents()) {
if (cmp.isDirty()) {
cmp.setDirty(false);
}
}
}
use of org.olat.core.gui.render.velocity.VelocityRenderDecorator in project openolat by klemens.
the class QTI21ResultsExportMediaResource method createResultHTML.
private String createResultHTML(Component results) {
String pagePath = Util.getPackageVelocityRoot(this.getClass()) + "/qti21results.html";
URLBuilder ubu = new URLBuilder("auth", "1", "0");
// generate VelocityContainer and put Component
VelocityContainer mainVC = new VelocityContainer("html", pagePath, translator, null);
mainVC.contextPut("rootTitle", translator.translate("table.grading"));
mainVC.put("results", results);
// render VelocityContainer to StringOutPut
Renderer renderer = Renderer.getInstance(mainVC, translator, ubu, new RenderResult(), new EmptyGlobalSettings());
try (StringOutput sb = new StringOutput(32000);
VelocityRenderDecorator vrdec = new VelocityRenderDecorator(renderer, mainVC, sb)) {
mainVC.contextPut("r", vrdec);
renderer.render(sb, mainVC, null);
vrdec.close();
return sb.toString();
} catch (Exception e) {
log.error("", e);
return "";
}
}
use of org.olat.core.gui.render.velocity.VelocityRenderDecorator in project openolat by klemens.
the class ExportBinderAsPDFResource method createResultHTML.
private String createResultHTML(Component content) {
String pagePath = Util.getPackageVelocityRoot(this.getClass()) + "/export.html";
VelocityContainer mainVC = new VelocityContainer("html", pagePath, translator, null);
mainVC.put("cmp", content);
mainVC.contextPut("bodyCssClass", "o_portfolio_export");
StringOutput sb = new StringOutput(32000);
URLBuilder ubu = new URLBuilder("auth", "1", "0");
Renderer renderer = Renderer.getInstance(mainVC, translator, ubu, new RenderResult(), new EmptyGlobalSettings());
VelocityRenderDecorator vrdec = new VelocityRenderDecorator(renderer, mainVC, sb);
mainVC.contextPut("r", vrdec);
renderer.render(sb, mainVC, null);
return sb.toString();
}
Aggregations