Search in sources :

Example 1 with ComponentRenderer

use of org.olat.core.gui.components.ComponentRenderer in project OpenOLAT by OpenOLAT.

the class DelegatingRenderer 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[])
 */
public void render(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
    ComponentRenderer cr = ((DelegatingComponent) source).getDelegateRenderer();
    cr.render(renderer, sb, source, ubu, translator, renderResult, args);
}
Also used : ComponentRenderer(org.olat.core.gui.components.ComponentRenderer)

Example 2 with ComponentRenderer

use of org.olat.core.gui.components.ComponentRenderer in project OpenOLAT by OpenOLAT.

the class SegmentViewRenderer method render.

@Override
public void render(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
    SegmentViewComponent component = (SegmentViewComponent) source;
    if (component.isEmpty() || (component.isDontShowSingleSegment() && component.getSegments().size() == 1)) {
        return;
    }
    sb.append("<div class='o_segments btn-group btn-group-justified'>");
    for (Component segment : component.getSegments()) {
        ComponentRenderer subRenderer = segment.getHTMLRendererSingleton();
        Translator subTranslator = segment.getTranslator();
        subRenderer.render(renderer, sb, segment, ubu, subTranslator, renderResult, args);
    }
    sb.append("</div>");
}
Also used : ComponentRenderer(org.olat.core.gui.components.ComponentRenderer) DefaultComponentRenderer(org.olat.core.gui.components.DefaultComponentRenderer) Translator(org.olat.core.gui.translator.Translator) Component(org.olat.core.gui.components.Component)

Example 3 with ComponentRenderer

use of org.olat.core.gui.components.ComponentRenderer in project OpenOLAT by OpenOLAT.

the class Renderer method render.

/**
 * used by the renderer, and also by the panel and tabbedpane renderer to delegate rendering
 * @param sb
 * @param source
 * @param args
 */
public void render(StringOutput sb, Component source, String[] args) {
    GlobalSettings gset = getGlobalSettings();
    boolean ajaxon = gset.getAjaxFlags().isIframePostEnabled();
    // wrap with div's so javascript can replace this component by doing a document.getElementById(cid).innerHTML and so on.
    boolean domReplaceable = source.isDomReplaceable();
    boolean useSpan = source.getSpanAsDomReplaceable();
    boolean domReplacementWrapperRequired = source.isDomReplacementWrapperRequired();
    boolean forceDebugDivs = gset.isIdDivsForced();
    if (source.isVisible()) {
        int lev = renderResult.getNestedLevel();
        if (lev > 60)
            throw new AssertException("components were nested more than 60 times, assuming endless loop bug: latest comp name: " + source.getComponentName());
        Translator componentTranslator = source.getTranslator();
        // identifier for dom replacement
        if (domReplaceable && domReplacementWrapperRequired && (ajaxon || forceDebugDivs)) {
            if (useSpan) {
                sb.append("<span id='o_c").append(source.getDispatchID());
            } else {
                sb.append("<div id='o_c").append(source.getDispatchID());
            }
            if (Settings.isDebuging()) {
            // sb.append("' title='").append(source.getComponentName());
            }
            sb.append("'>");
        }
        ComponentRenderer cr = findComponentRenderer(source);
        URLBuilder cubu = urlBuilder.createCopyFor(source);
        renderResult.incNestedLevel();
        // ---- for gui debug mode, direct the rendering to a special componentrenderer
        InterceptHandlerInstance dhi = renderResult.getInterceptHandlerInstance();
        if (dhi != null) {
            cr = dhi.createInterceptComponentRenderer(cr);
        }
        try {
            int preRenderLength = sb.length();
            cr.render(this, sb, source, cubu, componentTranslator, renderResult, args);
            if (preRenderLength == sb.length()) {
                // Add bugfix for IE min-height on empty div problem: min-height does
                // not get applied when div contains an empty comment.
                // Affects IE6, IE7
                sb.append("<!-- empty -->");
            }
            source.setDirty(false);
        } catch (Exception e) {
            // in order to produce a decent error msg, we need to postpone the
            // exception
            renderResult.setRenderExceptionInfo("exception while rendering component '" + source.getComponentName() + "' (" + source.getClass().getName() + ") " + source.getListenerInfo() + "<br />Message of exception: " + e.getMessage(), e);
        }
        renderResult.decNestedLevel();
        if (ajaxon && domReplaceable && domReplacementWrapperRequired) {
            if (useSpan) {
                sb.append("</span>");
            } else {
                sb.append("</div>");
            }
        }
    } else {
        // not visible
        if (domReplaceable && (ajaxon || forceDebugDivs)) {
            // browser dom tree
            if (useSpan) {
                sb.append("<span id=\"o_c").append(source.getDispatchID()).append("\"></span>");
            } else {
                // Add bugfix for IE min-height on empty div problem: min-height does
                // not get applied when div contains an empty comment.
                // Affects IE6, IE7
                sb.append("<div id=\"o_c").append(source.getDispatchID()).append("\"><!-- empty --></div>");
            }
        }
    }
}
Also used : AssertException(org.olat.core.logging.AssertException) ComponentRenderer(org.olat.core.gui.components.ComponentRenderer) Translator(org.olat.core.gui.translator.Translator) GlobalSettings(org.olat.core.gui.GlobalSettings) InterceptHandlerInstance(org.olat.core.gui.render.intercept.InterceptHandlerInstance) AssertException(org.olat.core.logging.AssertException)

Example 4 with ComponentRenderer

use of org.olat.core.gui.components.ComponentRenderer in project OpenOLAT by OpenOLAT.

the class Renderer method renderBodyOnLoadJSFunctionCall.

/**
 * renders the HTMLHeader-Part which this component comp needs. e.g. the
 * richtext component needs some css and javascript libraries an
 * velocity-container is a special case: it should collect the information
 * from all the children that are visible since all could be renderer. since
 * the actual rendering of a component depends on the page and is not know
 * beforehand, we could include some css/js which turns out not to be needed
 * in this request, but it is cached by the browser anyway, so it should not
 * matter to much. a little advice if you want to do it perfectly : program
 * the controller in such a way that they make a component invisible if not
 * needed
 *
 * @param sb
 * @param source
 * @see org.olat.core.gui.render.ui.ComponentRenderer
 */
public void renderBodyOnLoadJSFunctionCall(StringOutput sb, Component source, RenderingState rstate) {
    if (source != null && source.isVisible()) {
        ComponentRenderer cr = findComponentRenderer(source);
        cr.renderBodyOnLoadJSFunctionCall(this, sb, source, rstate);
    }
}
Also used : ComponentRenderer(org.olat.core.gui.components.ComponentRenderer)

Example 5 with ComponentRenderer

use of org.olat.core.gui.components.ComponentRenderer in project OpenOLAT by OpenOLAT.

the class Renderer method renderHeaderIncludes.

/**
 * @param sb
 * @param source
 */
public void renderHeaderIncludes(StringOutput sb, Component source, RenderingState rstate) {
    if (source != null && source.isVisible()) {
        ComponentRenderer cr = findComponentRenderer(source);
        URLBuilder cubu = urlBuilder.createCopyFor(source);
        cr.renderHeaderIncludes(this, sb, source, cubu, translator, rstate);
    }
}
Also used : ComponentRenderer(org.olat.core.gui.components.ComponentRenderer)

Aggregations

ComponentRenderer (org.olat.core.gui.components.ComponentRenderer)20 Translator (org.olat.core.gui.translator.Translator)10 Component (org.olat.core.gui.components.Component)8 RenderResult (org.olat.core.gui.render.RenderResult)6 Renderer (org.olat.core.gui.render.Renderer)6 RenderingState (org.olat.core.gui.render.RenderingState)6 StringOutput (org.olat.core.gui.render.StringOutput)6 URLBuilder (org.olat.core.gui.render.URLBuilder)6 DelegatingComponent (org.olat.core.gui.components.delegating.DelegatingComponent)4 IOException (java.io.IOException)2 PlainTextEditorController (org.olat.core.commons.editor.plaintexteditor.PlainTextEditorController)2 GlobalSettings (org.olat.core.gui.GlobalSettings)2 DefaultComponentRenderer (org.olat.core.gui.components.DefaultComponentRenderer)2 InlineTextElement (org.olat.core.gui.components.form.flexible.elements.InlineTextElement)2 Controller (org.olat.core.gui.control.Controller)2 BasicController (org.olat.core.gui.control.controller.BasicController)2 SourceViewController (org.olat.core.gui.dev.controller.SourceViewController)2 InterceptHandlerInstance (org.olat.core.gui.render.intercept.InterceptHandlerInstance)2 AssertException (org.olat.core.logging.AssertException)2