Examples of VelocityContext


Examples of org.apache.velocity.VelocityContext

 
  @Override
  public String render(PageEntity page, String template,
      String languageCode) {
    VosaoContext.getInstance().getPageRenderingContext().setPage(page);
    VelocityContext context = createContext(languageCode, page);
    context.put("page", createPageRenderDecorator(page, languageCode));
    return pagePostProcess(getSystemService().render(template, context),
        page);
  }
View Full Code Here

Examples of org.apache.velocity.VelocityContext

  @Override
  public VelocityContext createContext(final String languageCode,
      PageEntity page) {
    LanguageEntity language = getDao().getLanguageDao().getByCode(
        languageCode);
    VelocityContext context = new VelocityContext();
    ConfigEntity configEntity = getBusiness().getConfigBusiness().getConfig();
    addVelocityTools(context);
    context.put("language", language);
    context.put("locale", new Locale(language.getCode()));
    context.put("config", configEntity);
    context.put("service", getVelocityService());
    context.put("plugin", getVelocityPluginService().getPlugins());
    context.put("messages", getBusiness().getMessageBusiness().getBundle(
        languageCode));
    context.put("user", getBusiness().getUser());
    context.put("request", VosaoContext.getInstance().getRequest());
    context.put("response", VosaoContext.getInstance().getResponse());
    context.put("timezone", getBusiness().getTimeZone());
    VosaoTool vosaoTool = new VosaoTool();
    vosaoTool.setPage(page);
    context.put("vosao", vosaoTool);
    return context;
  }
View Full Code Here

Examples of org.apache.velocity.VelocityContext

    catch (IOException e) {
      logger.error(e.getMessage());
      return;
    }
    ConfigEntity config = VosaoContext.getInstance().getConfig();
    VelocityContext context = new VelocityContext();
    context.put("user", user);
    context.put("config", config);
    context.put("key", key);
    String letter = getSystemService().render(template, context);
    String error = EmailUtil.sendEmail(letter, "Forgot password",
        config.getSiteEmail(), "Site admin", email);
    if (error != null) {
      logger.error(error);
View Full Code Here

Examples of org.apache.velocity.VelocityContext

   * this is more a playground method to understand the evaluate method than a
   * rela testcase
   */
  public void testVelocityTemplate() {
    //
    VelocityContext context = new VelocityContext();
    // good case
    StringWriter writer = new StringWriter();
    context.put("foo", new String("bar"));
    String template = "foo $foo";
    MailerResult result = new MailerResult();
    MailerWithTemplate.getInstance().evaluate(context, template, writer, result);
    assertEquals(MailerResult.OK, result.getReturnCode());
    assertEquals("foo bar", writer.toString());
View Full Code Here

Examples of org.apache.velocity.VelocityContext

      if (form == null) {
        return Messages.get("form.not_found", formName);
      }
      List<FieldEntity> fields = getDao().getFieldDao().getByForm(form);
      FormConfigEntity formConfig = getDao().getFormConfigDao().getConfig();
      VelocityContext context = getPageBusiness().createContext(
        getBusiness().getLanguage(), null);
      context.put("formConfig", formConfig);
      context.put("form", form);
      context.put("fields", fields);
      if (StringUtils.isEmpty(formConfig.getFormTemplate())) {
        return Messages.get("form.template_is_empty");
      }
      return getSystemService().render(formConfig.getFormTemplate(),
          context);
View Full Code Here

Examples of org.apache.velocity.VelocityContext

  private String getConfirmation(UserRequest ureq, String filename) {
    // grab standard text
    String confirmation = translate("conf.stdtext");
    config.set(TACourseNode.CONF_DROPBOX_CONFIRMATION, confirmation);
   
    Context c = new VelocityContext();
    Identity identity = ureq.getIdentity();
    c.put("login", identity.getName());
    c.put("first", identity.getUser().getProperty(UserConstants.FIRSTNAME, getLocale()));
    c.put("last", identity.getUser().getProperty(UserConstants.LASTNAME, getLocale()));
    c.put("email", identity.getUser().getProperty(UserConstants.EMAIL, getLocale()));
    c.put("filename", filename);
    Date now = new Date();
    Formatter f = Formatter.getInstance(ureq.getLocale());
    c.put("date", f.formatDate(now));
    c.put("time", f.formatTime(now));
   
    // update attempts counter for this user: one file - one attempts
    AssessableCourseNode acn = (AssessableCourseNode) node;
    acn.incrementUserAttempts(userCourseEnv);
       
View Full Code Here

Examples of org.apache.velocity.VelocityContext

          }
        } else {
          userDataArray.add(userLanguage);
        }

        Context vcContext = new VelocityContext();
        // set all properties as context
        ubcMan.setUserContext(identity, vcContext, isAdministrativeUser);
        // loop for each property configured in
        // src/serviceconfig/org/olat/_spring/olat_userconfig.xml -> Key:
        // org.olat.admin.user.bulkChange.UserBulkChangeStep00
View Full Code Here

Examples of org.apache.velocity.VelocityContext

          preferences.setLanguage(inputLanguage);
          user.setPreferences(preferences);
        }
      }

      Context vcContext = new VelocityContext();
      // set all properties as context
      setUserContext(identity, vcContext, isAdministrativeUser);
      // loop for each property configured in
      // src/serviceconfig/org/olat/_spring/olat_userconfig.xml -> Key:
      // org.olat.admin.user.bulkChange.UserBulkChangeStep00
View Full Code Here

Examples of org.apache.velocity.VelocityContext

    Translator propertyTrans = Util.createPackageTranslator(UserPropertyHandler.class, locale);
    return getDemoContext(propertyTrans, isAdministrativeUser);
  }
 
  public Context getDemoContext(Translator propertyTrans, boolean isAdministrativeUser) {
    Context vcContext = new VelocityContext();
    List<UserPropertyHandler> userPropertyHandlers2;
    userPropertyHandlers2 = UserManager.getInstance().getAllUserPropertyHandlers();
    for (UserPropertyHandler userPropertyHandler : userPropertyHandlers2) {
      String propertyName = userPropertyHandler.getName();
      String userValue = propertyTrans.translate("import.example." + userPropertyHandler.getName());
      vcContext.put(propertyName, userValue);
    }
    return vcContext;
  }
View Full Code Here

Examples of org.apache.velocity.VelocityContext

        .getCommentsTemplate();
      if (StringUtils.isEmpty(commentsTemplate)) {
        logger.error(Messages.get("config.comments_template_is_empty"));
        return Messages.get("config.comments_template_is_empty");
      }
      VelocityContext context = getPageBusiness().createContext(
          getLanguageCode(), getPage());
      context.put("page", getPage());
      return getSystemService().render(commentsTemplate, context);
    }
    return "";
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.