Package org.olat.core.gui.media

Examples of org.olat.core.gui.media.StringMediaResource


        } else {
          // something is wrong, maybe some hacker attack
          logError("Got a tree data mapper request but node parameter is missing. Root node title was::" + titleRootNode, null);
          data = "";
        }
        StringMediaResource mediaResource = new StringMediaResource();
        mediaResource.setEncoding(ENCODING_UTF_8);
        mediaResource.setContentType(CONTENT_TYPE_JAVASCRIPT);
        mediaResource.setData(data);
        return mediaResource;
      }
    };
    String dataMapperUri = registerMapper(treeDataMapper);
    mainVC.contextPut("dataMapperUri", dataMapperUri);
View Full Code Here


        int position = Integer.parseInt(index);
        // notify parent controller about the move
        MoveTreeNodeEvent moveEvent = new MoveTreeNodeEvent(node, oldParent, newParent, position);
        fireEvent(ureq, moveEvent);
        // prepare response as javascript string
        StringMediaResource smr = new StringMediaResource();
        // content type javascript forces menu tree to eval result
        smr.setContentType(CONTENT_TYPE_JAVASCRIPT);
        smr.setEncoding(ENCODING_UTF_8);
        if (moveEvent.isResultSuccess()) {
          // send ok back
          smr.setData("b_amt_status=true;");
        } else {
          // send failure and some messages for the user
          smr.setData("b_amt_status_title=\"" + moveEvent.getResultFailureTitle() + "\", b_amt_status_msg=\""
              + moveEvent.getResultFailureMessage() + "\"; b_amt_status=false;");
        }
        ureq.getDispatchResult().setResultingMediaResource(smr);

      } else if (event.getCommand().equals(CMD_CLICK)) {
View Full Code Here

    String[] parts = relPath.split("/");
    String localeKey = parts[1];
    String bundleName = parts[2];
    Locale locale = i18nManager.getLocaleOrDefault(localeKey);
    // Create a media resource   
    StringMediaResource resource = new StringMediaResource() {
      @Override
      public void prepare(HttpServletResponse hres) {
        // don't use normal string media headers which prevent caching,
        // use standard browser caching based on last modified timestamp
      }
    };
    resource.setLastModified(i18nManager.getLastModifiedDate(locale, bundleName));
    resource.setContentType("text/javascript");
    // Get the translation data
    String translationData = i18nManager.getJSTranslatorData(locale, bundleName);
    resource.setData(translationData);
    // UTF-8 encoding used in this js file since explicitly set in the ajax
    // call (usually js files are 8859-1)
    resource.setEncoding("utf-8");
    return resource;
  }
View Full Code Here

          res = sb.toString();
    } else {
      res = jsonText;
    }

    StringMediaResource smr = new StringMediaResource();
    smr.setContentType("text/html;charset=utf-8");
    // TODO: check if it worked also with text/javascript
    smr.setEncoding("utf-8");
    smr.setData(res);
    return smr;
  }
View Full Code Here

         options.setShowLineNumbers(true);
        converter.convert(jsource, options, writer);
      } catch (IOException e) {
        //
      }
      StringMediaResource mr = new StringMediaResource();
      mr.setContentType(TEXT_HTML_CHARSET_UTF_8);
      writer.append(HTML_STOP);
      mr.setData(writer.toString());
      ureq.getDispatchResult().setResultingMediaResource(mr);
    }

  }
View Full Code Here

      converter.convert(jsource, JavaSourceConversionOptions.getDefault(), writer);
    } else {
      writer.append("<html><body><h3>The source file could not be found in the following path:<br>"+javaSourcePath+"<br>Check if configured source path in brasatoconfig.xml is correct.</h3></body></html>");
    }
   
    StringMediaResource mr = new StringMediaResource();
    mr.setContentType(TEXT_HTML_CHARSET_UTF_8);
    writer.append(HTML_STOP);
    mr.setData(writer.toString());
    return mr;
   
  }
View Full Code Here

        if (level.equals("debug")) {
          // log to standard OLAT logging system
          logDebug(logMsg, jsFile);
        }
        // sent empty response
        StringMediaResource smr = new StringMediaResource();
        smr.setContentType("application/javascript");
        smr.setEncoding("utf-8");
        smr.setData("");
        StringMediaResource mediaResource = new StringMediaResource();
        mediaResource.setEncoding("utf-8");
        mediaResource.setContentType("text/javascript;charset=utf-8");
        mediaResource.setData("");
        return mediaResource;
      }
    };
    String mapperUri = registerMapper(mapper);
View Full Code Here

          useLoaded = true;
        }
        // set the new encoding to remember for any following .js file loads
        g_encoding = enc;
        if (useLoaded) {
          StringMediaResource smr = new StringMediaResource();
          String mimetype = "text/html;charset=" + enc;
          smr.setContentType(mimetype);
          smr.setEncoding(enc);
          smr.setData(page);
          mr = smr;
        } else {
          // found a new charset other than iso-8859-1 -> let it load again
          // as bytes (so we do not need to convert to string and back
          // again)
View Full Code Here

      public MediaResource handle(String relPath, HttpServletRequest request) {
        String lastN = request.getParameter("qs");
        AutoCompleterListReceiver receiver = new AutoCompleterListReceiver(noresults);
        gprovider.getResult(lastN, receiver);
        String html = receiver.getResult();
        StringMediaResource smr = new StringMediaResource();
        smr.setContentType("text/html");
        smr.setEncoding("utf-8");
        smr.setData(html);
        return smr;
      }
    };
    String fetchUri = registerMapper(mapper);
    final String fulluri = fetchUri; // + "/" + fileName;
View Full Code Here

    }
    return mr;
  }

  private StringMediaResource prepareMediaResource(String page, String enc, boolean isPopUp) {
    StringMediaResource smr = new StringMediaResource();
    String mimetype = MIMETYPE + StringHelper.check4xMacRoman(enc);
    smr.setContentType(mimetype);
    smr.setEncoding(enc);
    //inject some javascript code to size iframe to proper height, but only when not a page with framesets
    if (page.indexOf(TAG_FRAMESET) != -1 || page.indexOf(TAG_FRAMESET_UPPERC) != -1 || isPopUp) {
      //is frameset -> deliver unparsed
      smr.setData(page);     
    } else {
      smr.setData(injectJavaScript(page, checkForInlineEvent));     
      // When loading next page, check if it was an inline user click
      this.checkForInlineEvent = true;

    }
    return smr;
View Full Code Here

TOP

Related Classes of org.olat.core.gui.media.StringMediaResource

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.