Search in sources :

Example 1 with VelocityHelper

use of org.olat.core.gui.render.velocity.VelocityHelper 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);
        }
    }
}
Also used : Context(org.apache.velocity.context.Context) ComponentRenderer(org.olat.core.gui.components.ComponentRenderer) Renderer(org.olat.core.gui.render.Renderer) VelocityHelper(org.olat.core.gui.render.velocity.VelocityHelper) Component(org.olat.core.gui.components.Component) VelocityRenderDecorator(org.olat.core.gui.render.velocity.VelocityRenderDecorator)

Example 2 with VelocityHelper

use of org.olat.core.gui.render.velocity.VelocityHelper in project openolat by klemens.

the class AssessmentObjectComponentRenderer method renderVelocity.

private void renderVelocity(AssessmentRenderer renderer, StringOutput sb, QtiNode interaction, Context ctx, String page, ResolvedAssessmentItem resolvedAssessmentItem, ItemSessionState itemSessionState, AssessmentObjectComponent component, URLBuilder ubu, Translator translator) {
    ctx.put("localName", interaction.getQtiClassName());
    ctx.put("assessmentItem", resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful());
    ctx.put("itemSessionState", itemSessionState);
    ctx.put("isItemSessionOpen", component.isItemSessionOpen(itemSessionState, renderer.isSolutionMode()));
    ctx.put("isItemSessionEnded", component.isItemSessionEnded(itemSessionState, renderer.isSolutionMode()));
    Renderer fr = Renderer.getInstance(component, translator, ubu, new RenderResult(), renderer.getGlobalSettings());
    AssessmentRenderer fHints = renderer.newHints(fr);
    try (AssessmentObjectVelocityRenderDecorator vrdec = new AssessmentObjectVelocityRenderDecorator(fHints, sb, component, resolvedAssessmentItem, itemSessionState, ubu, translator)) {
        ctx.put("r", vrdec);
        VelocityHelper vh = VelocityHelper.getInstance();
        vh.mergeContent(page, ctx, sb, null);
        ctx.remove("r");
    } catch (IOException e) {
        log.error("", e);
    }
}
Also used : Renderer(org.olat.core.gui.render.Renderer) DefaultComponentRenderer(org.olat.core.gui.components.DefaultComponentRenderer) RenderResult(org.olat.core.gui.render.RenderResult) VelocityHelper(org.olat.core.gui.render.velocity.VelocityHelper) IOException(java.io.IOException)

Example 3 with VelocityHelper

use of org.olat.core.gui.render.velocity.VelocityHelper in project OpenOLAT by OpenOLAT.

the class AssessmentObjectComponentRenderer method renderVelocity.

private void renderVelocity(AssessmentRenderer renderer, StringOutput sb, QtiNode interaction, Context ctx, String page, ResolvedAssessmentItem resolvedAssessmentItem, ItemSessionState itemSessionState, AssessmentObjectComponent component, URLBuilder ubu, Translator translator) {
    ctx.put("localName", interaction.getQtiClassName());
    ctx.put("assessmentItem", resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful());
    ctx.put("itemSessionState", itemSessionState);
    ctx.put("isItemSessionOpen", component.isItemSessionOpen(itemSessionState, renderer.isSolutionMode()));
    ctx.put("isItemSessionEnded", component.isItemSessionEnded(itemSessionState, renderer.isSolutionMode()));
    Renderer fr = Renderer.getInstance(component, translator, ubu, new RenderResult(), renderer.getGlobalSettings());
    AssessmentRenderer fHints = renderer.newHints(fr);
    try (AssessmentObjectVelocityRenderDecorator vrdec = new AssessmentObjectVelocityRenderDecorator(fHints, sb, component, resolvedAssessmentItem, itemSessionState, ubu, translator)) {
        ctx.put("r", vrdec);
        VelocityHelper vh = VelocityHelper.getInstance();
        vh.mergeContent(page, ctx, sb, null);
        ctx.remove("r");
    } catch (IOException e) {
        log.error("", e);
    }
}
Also used : Renderer(org.olat.core.gui.render.Renderer) DefaultComponentRenderer(org.olat.core.gui.components.DefaultComponentRenderer) RenderResult(org.olat.core.gui.render.RenderResult) VelocityHelper(org.olat.core.gui.render.velocity.VelocityHelper) IOException(java.io.IOException)

Example 4 with VelocityHelper

use of org.olat.core.gui.render.velocity.VelocityHelper in project openolat by klemens.

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);
        }
    }
}
Also used : Context(org.apache.velocity.context.Context) ComponentRenderer(org.olat.core.gui.components.ComponentRenderer) Renderer(org.olat.core.gui.render.Renderer) VelocityHelper(org.olat.core.gui.render.velocity.VelocityHelper) Component(org.olat.core.gui.components.Component) VelocityRenderDecorator(org.olat.core.gui.render.velocity.VelocityRenderDecorator)

Aggregations

Renderer (org.olat.core.gui.render.Renderer)4 VelocityHelper (org.olat.core.gui.render.velocity.VelocityHelper)4 IOException (java.io.IOException)2 Context (org.apache.velocity.context.Context)2 Component (org.olat.core.gui.components.Component)2 ComponentRenderer (org.olat.core.gui.components.ComponentRenderer)2 DefaultComponentRenderer (org.olat.core.gui.components.DefaultComponentRenderer)2 RenderResult (org.olat.core.gui.render.RenderResult)2 VelocityRenderDecorator (org.olat.core.gui.render.velocity.VelocityRenderDecorator)2