Package org.olat.core.gui.render

Examples of org.olat.core.gui.render.StringOutput


   * @return
   */
  public StringOutput renderWizardSteps(String strStep, String strMaxStep) {
    int step = Integer.parseInt(strStep);
    int maxStep = Integer.parseInt(strMaxStep);
    StringOutput sb = new StringOutput(100);
    renderWizardSteps(sb, maxStep, step);
    return sb;
  }
View Full Code Here


          // render initial state of new window by redirecting (302) to the new
          // window id. needed for asyncronous data like images loaded
         
          // todo maybe better delegate window registry to the windowbackoffice?
          URLBuilder ubu = new URLBuilder(uriPrefix, resWindow.getInstanceId(), String.valueOf(resWindow.timestamp), resWindow.wbackofficeImpl);
          StringOutput sout = new StringOutput(30);
          ubu.buildURI(sout, null, null);
          mr = new RedirectMediaResource(sout.toString());
          ServletUtil.serveResource(request, response, mr);
          if (isDebugLog) {
            long diff = System.currentTimeMillis() - debug_start;
            debugMsg.append("rdirnw:").append(diff).append(LOG_SEPARATOR);
            Tracing.logDebug(debugMsg.toString(), Window.class);
View Full Code Here

              }
             
              Panel wrapper = new Panel("renderpanel");
              wrapper.setDomReplaceable(false); // to omit <div> around the render helper panel
              RenderResult renderResult = null;
              StringOutput jsol = new StringOutput();
              StringOutput hdr = new StringOutput();
              String result = null;
              try {
                toRender.setDomReplaceable(false);
                wrapper.setContent(toRender);
                String newTimestamp = String.valueOf(timestamp);
                URLBuilder ubu = new URLBuilder(uriPrefix,getInstanceId(), newTimestamp,wbackofficeImpl);

                renderResult = new RenderResult();

                // if we have an around-component-interception
                // set the handler for this render cycle
                InterceptHandler interceptHandler = wbackofficeImpl.getInterceptHandler();
                if (interceptHandler != null) {
                  InterceptHandlerInstance dhri = interceptHandler.createInterceptHandlerInstance();
                  renderResult.setInterceptHandlerRenderInstance(dhri);
                }

                Renderer fr = Renderer.getInstance(wrapper,null, ubu, renderResult, gsettings);

                jsol = new StringOutput();
                fr.renderBodyOnLoadJSFunctionCall(jsol,toRender);

                hdr = new StringOutput();
                fr.renderHeaderIncludes(hdr, toRender);

                long pstart = 0;
                if (isDebugLog) {
                  pstart = System.currentTimeMillis();
View Full Code Here

   * @param bc the businesscontrolpath
   * @return the new (relative) url as a string
   */
  private String buildURIFor(Window win, String timestampId, String moduleUri) {
    URLBuilder ubu = new URLBuilder(uriPrefix, win.getInstanceId(), timestampId, wbackofficeImpl);
    StringOutput so = new StringOutput();
    ubu.buildURI(so, null, null, moduleUri, 0);
    String uri = so.toString();
    return uri;
 
View Full Code Here


    String exDate = jsdcc.getExampleDateString();
    maxlength = exDate.length() + 4;
   
    StringOutput content = new StringOutput();
    renderTextElementPart(content, jsdcc.getTextElementComponent());
   
    //
    String triggerId = "trigger_" + jsdcc.getFormDispatchId();
    Translator sourceTranslator = jsdcc.getElementTranslator();

   
    /*
     * add pop js for date chooser, if componente is enabled
     */
    if (source.isEnabled()) {
     
      //date chooser button
      content.append("<span class=\"b_form_datechooser\" id=\"").append(triggerId).append("\" title=\"").append(StringEscapeUtils.escapeHtml(sourceTranslator.translate("calendar.choose"))).append("\">&nbsp;</span>");
      // date chooser javascript
      content.append("<script type=\"text/javascript\">\n /* <![CDATA[ */ \n").append("Calendar.setup({").append("inputField:\"").append(receiverId).append("\",")
          .append("ifFormat:\"");
      if (jsdcc.getDateChooserDateFormat() == null) {
        // use default format from default locale file

        Formatter formatter = Formatter.getInstance(translator.getLocale());
        if (jsdcc.isDateChooserTimeEnabled()) content.append(formatter.getSimpleDatePatternForDateAndTime());
        else content.append(formatter.getSimpleDatePatternForDate());

      } else {
        // use custom date format
        content.append(jsdcc.getDateChooserDateFormat());
      }
      content.append("\",").append("button:\"").append(triggerId).append("\",").append("align:\"Tl\",").append("singleClick:false,");
      if (jsdcc.isDateChooserTimeEnabled()) {
        content.append("showsTime:true,");
        content.append("timeFormat:\"24\",");
      }
      content.append("cache:true,").append("firstDay:1,").append("showOthers:true,");
      // Call on change method on input field to trigger dirty button
      TextElementComponent teC = jsdcc.getTextElementComponent();
      TextElementImpl te = teC.getTextElementImpl();
      content.append("onUpdate:function(){setFlexiFormDirty('").append(te.getRootForm().getDispatchFieldId()).append("')}");
      // Finish js code
      content.append("});").append("\n/* ]]> */ \n</script>");
      sb.append(content);
    } else{
      //readonly view
      FormJSHelper.appendReadOnly(content.toString(), sb);
    }

  }
View Full Code Here

    input.setTopicName("dummy");
    input.setUserIpAddress("0.0.0.0");
    OlatWikiDataHandler dataHandler = new OlatWikiDataHandler(wikiComp.getOres(), wikiComp.getImageBaseUri());
    input.setDataHandler(dataHandler);
   
    StringOutput out = new StringOutput();
    ubu.buildURI(out, null , null, iframePostEnabled ? AJAXFlags.MODE_TOBGIFRAME : AJAXFlags.MODE_NORMAL);
    String uri = out.toString();
   
    ParserDocument parsedDoc = null;

   
   
    String uniqueId = "o_wiki"+wikiComp.getDispatchID();
    try {
      uri = URLDecoder.decode(uri, "utf-8");
      input.setVirtualWiki(uri.substring(1, uri.length()-1));
      if (iframePostEnabled) {
        StringOutput so = new StringOutput();
        ubu.appendTarget(so);
        input.setURLTarget(so.toString());
      }
      sb.append("<div style=\"min-height:"+ wikiComp.getMinHeight() +"px\" id=\"");
      sb.append(uniqueId);
      sb.append("\">");
   
View Full Code Here

        +  plainVanillaPlain   +  I18nManager.IDENT_PREFIX + combinedKey + ":\\1" + I18nManager.IDENT_END_POSTFIX);
    Matcher m = plainVanillaWrappedPattern.matcher(plainVanillaWrapped);
    assertTrue(m.find());
   
    // test find-replace translator identifyers with HTML markup
    StringOutput inlineTransLink = new StringOutput();
    InlineTranslationInterceptHandlerController.buildInlineTranslationLink(combinedKey + ":1000000001", inlineTransLink, inlineTrans, inlineTranslationURLBuilder);
    // Plain vanilla text
    String convertedToHTMLMarkup = InlineTranslationInterceptHandlerController.replaceLocalizationMarkupWithHTML(plainVanillaWrapped, inlineTranslationURLBuilder, inlineTrans);
    assertEquals("<span class=\"b_translation_i18nitem\">" + inlineTransLink.toString() + plainVanillaPlain + "</span>", convertedToHTMLMarkup);
    // Simple link   
    String linkOPEN = "<a href=\"http://www.olat.org/bla/blu:bli#bla\" title='funny title' class=\"b_css b_anothercss\">";
    String linkCLOSE = "</a>";
    String inlineSpanOPEN = "<span class=\"b_translation_i18nitem\">";
    String inlineSpanCLOSE = "</span>";
    String translatedWithinLink =  linkOPEN + plainVanillaWrapped + linkCLOSE + rawtext1;
    convertedToHTMLMarkup = InlineTranslationInterceptHandlerController.replaceLocalizationMarkupWithHTML(translatedWithinLink, inlineTranslationURLBuilder, inlineTrans);
    String convertedWithinLinkExpected = inlineSpanOPEN + inlineTransLink.toString() + linkOPEN + plainVanillaPlain + linkCLOSE + inlineSpanCLOSE + rawtext1;
    assertEquals(convertedWithinLinkExpected, convertedToHTMLMarkup);
    // Simple link with span
    String linkSpanOPEN = "<span class=\"bluber\">";
    String linkSpanCLOSE = "</span>";
    String translatedWithinLinkAndSpan = rawtext2 + linkOPEN + linkSpanOPEN + plainVanillaWrapped + linkSpanCLOSE + linkCLOSE;
    convertedToHTMLMarkup = InlineTranslationInterceptHandlerController.replaceLocalizationMarkupWithHTML(translatedWithinLinkAndSpan, inlineTranslationURLBuilder, inlineTrans);
    String convertedWithinLinkAndSpanExpected = rawtext2 + inlineSpanOPEN + inlineTransLink.toString() + linkOPEN + linkSpanOPEN + plainVanillaPlain + linkSpanCLOSE + linkCLOSE + inlineSpanCLOSE;
    assertEquals(convertedWithinLinkAndSpanExpected, convertedToHTMLMarkup);
    // Muliple links
    String translatedWithinMultipleLinks =  translatedWithinLink + translatedWithinLinkAndSpan + translatedWithinLinkAndSpan;
    convertedToHTMLMarkup = InlineTranslationInterceptHandlerController.replaceLocalizationMarkupWithHTML(translatedWithinMultipleLinks, inlineTranslationURLBuilder, inlineTrans);
    String convertedWithinMultipleLinksExpected = convertedWithinLinkExpected + convertedWithinLinkAndSpanExpected + convertedWithinLinkAndSpanExpected;
    assertEquals(convertedWithinMultipleLinksExpected, convertedToHTMLMarkup);
    // Input elements
    String inputOPEN = "<input type='submit' class=\"bluber\" value=\"";
    String inputCLOSE = "\" />";
    String translatedWithinInput = inputOPEN + plainVanillaWrapped + inputCLOSE + rawtext1;
    convertedToHTMLMarkup = InlineTranslationInterceptHandlerController.replaceLocalizationMarkupWithHTML(translatedWithinInput, inlineTranslationURLBuilder, inlineTrans);
    String convertedWithinInputExpected = inlineSpanOPEN + inlineTransLink.toString() + inputOPEN + plainVanillaPlain + inputCLOSE + inlineSpanCLOSE + rawtext1;
    assertEquals(convertedWithinInputExpected, convertedToHTMLMarkup);
    // checkbox elements
    String checkboxOPEN = "<input type='submit' class=\"bluber\" type=\"checkbox\" value=\"";
    String checkboxCLOSE = "\" />";
    String translatedWithinCheckbox = checkboxOPEN + plainVanillaWrapped + checkboxCLOSE + rawtext1;
View Full Code Here

  private String getRedirectToURL(UserSession usess) {
    ChiefController cc = (ChiefController) Windows.getWindows(usess).getAttribute("AUTHCHIEFCONTROLLER");
    Window w = cc.getWindow();
   
    URLBuilder ubu = new URLBuilder("", w.getInstanceId(), String.valueOf(w.getTimestamp()), null);
    StringOutput sout = new StringOutput(30);
    ubu.buildURI(sout, null, null);
   
    return WebappHelper.getServletContextPath() + DispatcherAction.PATH_AUTHENTICATED + sout.toString();
  }
View Full Code Here

  /**
   * @see org.olat.core.gui.components.table.ColumnDescriptor#renderValue(org.olat.core.gui.render.StringOutput, int, org.olat.core.gui.render.Renderer)
   */
  public void renderValue(StringOutput sb, int row, Renderer renderer) {
    StringOutput sbuf = new StringOutput();
    super.renderValue(sbuf, row, renderer);
    String val = sbuf.toString();
    Object m = messages.get(getTable().getSortedRow(row));
    GenericTraversalNode gtn = getTreeWalker().getGenericTraversalNode(m);
    // + "..."+gtn.getDepth()+", vnr:"+gtn.getVisitNumber();
    sb.append("<div style=\"white-space: nowrap;"); // do not wrap titles, looks unsexy
    int indent = gtn.getDepth(); // starts with 1
View Full Code Here

   * @param translator
   * @param renderer
   * @return rendered form
   */
  public StringOutput buildForm(IQComponent comp, Translator translator, Renderer renderer, URLBuilder ubu) {
    StringOutput sb = new StringOutput();
    Info info = comp.getAssessmentInstance().getNavigator().getInfo();
    AssessmentInstance ai = comp.getAssessmentInstance();
    int status = info.getStatus();
    int message = info.getMessage();
    boolean renderItems = info.isRenderItems();
    AssessmentContext act = ai.getAssessmentContext();

    // first treat messages and errors
    if (info.containsMessage()) {
      switch (message) {
        case QTIConstants.MESSAGE_ITEM_SUBMITTED :         
          //item hints?
          if (info.isHint()) {
            Hint el_hint = info.getCurrentOutput().getHint();
            if (el_hint.getFeedbackstyle() == Hint.FEEDBACKSTYLE_INCREMENTAL) {
              // increase the hint level so we know which hint to display
              ItemContext itc = act.getCurrentSectionContext().getCurrentItemContext();
              int nLevel = itc.getHintLevel() + 1;
              int numofhints = el_hint.getChildCount();
              if (nLevel > numofhints) nLevel = numofhints;
              itc.setHintLevel(nLevel);
              //<!ELEMENT hint (qticomment? , hintmaterial+)>
             
              displayFeedback(sb, (GenericQTIElement)el_hint.getChildAt(nLevel-1), ai, translator.getLocale());
            } else {
              displayFeedback(sb, el_hint, ai, translator.getLocale());
            }
          }
          //item solution?
          if (info.isSolution()) {
            Solution el_solution = info.getCurrentOutput().getSolution();
            displayFeedback(sb, el_solution, ai, translator.getLocale());
          }
          // item fb?
          if (info.isFeedback()) {
            if (info.getCurrentOutput().hasItem_Responses()) {
              int fbcount = info.getCurrentOutput().getFeedbackCount();
              int i=0;
              while (i < fbcount) {
                Element el_anschosen = info.getCurrentOutput().getItemAnswerChosen(i);
                if (el_anschosen != null) {
                  sb.append("<br /><br /><i>");
                  displayFeedback(sb, new Material(el_anschosen), ai, translator.getLocale());
                  sb.append("</i>");
                }
                Element el_resp= info.getCurrentOutput().getItemFeedback(i);
                displayFeedback(sb, new ItemFeedback(el_resp), ai, translator.getLocale());
                i++;
              }
            }
          }
          if(!comp.getMenuDisplayConf().isEnabledMenu() && comp.getMenuDisplayConf().isItemPageSequence() && !info.isRenderItems()) {
            //if item was submitted and sequence is pageSequence and menu not enabled and isRenderItems returns false show section info
            SectionContext sc = ai.getAssessmentContext().getCurrentSectionContext();
            displaySectionInfo(sb, sc, ai, comp, ubu, translator);
          }
          break;

        case QTIConstants.MESSAGE_SECTION_SUBMITTED :
          //  provide section feedback if enabled and existing
          //SectionContext sc = act.getCurrentSectionContext();         
          if (info.isFeedback()) {
            Output outp = info.getCurrentOutput();
            GenericQTIElement el_feedback = outp.getEl_response();
            if (el_feedback != null) displayFeedback(sb, el_feedback, ai, translator.getLocale());
          }
          if(!comp.getMenuDisplayConf().isEnabledMenu() && !comp.getMenuDisplayConf().isItemPageSequence()) {
            SectionContext sc = ai.getAssessmentContext().getCurrentSectionContext();
            displaySectionInfo(sb, sc, ai, comp, ubu, translator);
          }
          break;

        case QTIConstants.MESSAGE_ASSESSMENT_SUBMITTED :
          //  provide assessment feedback if enabled and existing
          if (info.isFeedback()) {
            Output outp = info.getCurrentOutput();
            GenericQTIElement el_feedback = outp.getEl_response();
            if (el_feedback != null) displayFeedback(sb, el_feedback, ai, translator.getLocale());
          }
          break;

        case QTIConstants.MESSAGE_SECTION_INFODEMANDED : // for menu item navigator
          // provide some stats maybe
          SectionContext sc = ai.getAssessmentContext().getCurrentSectionContext();
          displaySectionInfo(sb, sc, ai, comp, ubu, translator);
          break;

        case QTIConstants.MESSAGE_ASSESSMENT_INFODEMANDED : // at the start of the test
          displayAssessmentInfo(sb, act, ai, comp, ubu, translator);
          break;
      }
    }

    if (renderItems) {
      boolean displayForm = true;
      // First check wether we need to render a form.
      // No form is needed if the current item has a matapplet object to be displayed.
      // Matapplets will send their response back directly.
      SectionContext sct = act.getCurrentSectionContext();
      ItemContext itc = null;
      if (sct != null && !ai.isSectionPage()) {
        itc = sct.getCurrentItemContext();
        if (itc != null) {
          Item item = itc.getQtiItem();
          if (item.getQTIIdent().startsWith("QTIEDIT:FLA:")) displayForm = false;
        }
      }
     
      sb.append("<form action=\"");
      ubu.buildURI(sb, new String[] { VelocityContainer.COMMAND_ID }, new String[] { "sitse" });
     
      sb.append("\" id=\"ofo_iq_item\" method=\"post\">");

      if (!ai.isSectionPage()) {
        if (itc != null) displayItem(sb, renderer, ubu, itc, ai);
      } else {
        if (sct != null && sct.getItemContextCount() != 0)
          displayItems(sb, renderer, ubu, sct, ai);
      }
     
      sb.append("<div class=\"b_button_group\"><input class=\"b_button\" type=\"submit\" name=\"olat_fosm\" value=\"");
      if (ai.isSectionPage())
        sb.append(StringEscapeUtils.escapeHtml(translator.translate("submitMultiAnswers")));
      else
        sb.append(StringEscapeUtils.escapeHtml(translator.translate("submitSingleAnswer")));
      sb.append("\"");
      if (!displayForm) sb.append(" style=\"display: none;\"");
      sb.append(" /></div></form>");
    }

    if (status == QTIConstants.ASSESSMENT_FINISHED) {
      if (info.isFeedback()) {
        Output outp = info.getCurrentOutput();
View Full Code Here

TOP

Related Classes of org.olat.core.gui.render.StringOutput

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.