Package org.apache.velocity.context

Examples of org.apache.velocity.context.Context


    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


   */
  private void initTransformer() {
    // build new transformer
    InputStream xslin = getClass().getResourceAsStream("/org/olat/ims/resources/xsl/" + XSLFILENAME);
    // translate xsl with velocity
    Context vcContext = new VelocityContext();
    vcContext.put("t", pT);
    vcContext.put("staticPath", StaticMediaDispatcher.createStaticURIFor(""));
    String xslAsString = "";
    try {
      xslAsString = slurp(xslin);
    } catch (IOException e) {
      log.error("Could not convert xsl to string!", e);
View Full Code Here

    //to validate the input a special isValidValue is used.
    if (usageIdentifyer.equals(UserBulkChangeStep00.class.getCanonicalName())){
      tElem.setItemValidatorProvider(new ItemValidatorProvider(){
        public boolean isValidValue(String value, ValidationError validationError, Locale locale2) {
          UserBulkChangeManager ubcMan = UserBulkChangeManager.getInstance();
          Context vcContext = new VelocityContext();
          if (user==null){
            vcContext = ubcMan.getDemoContext(locale2, isAdministrativeUser);
          }
          //should be used if user-argument !=null --> move to right place
          else {
View Full Code Here

     *
     * @return A Context object.
     */
    public Context getContext()
    {
        Context globalContext =
                pullModelActive ? pullService.getGlobalContext() : null;

        Context ctx = new VelocityContext(globalContext);
        return ctx;
    }
View Full Code Here

     *
     * @return A Context Object.
     */
    public Context getNewContext()
    {
        Context ctx = new VelocityContext();

        // Attach an Event Cartridge to it, so we get exceptions
        // while invoking methods from the Velocity Screens
        EventCartridge ec = new EventCartridge();
        ec.addEventHandler(this);
View Full Code Here

     * @exception Exception, a generic exception.
     */
    public ConcreteElement buildTemplate(RunData data)
            throws Exception
    {
        Context context = TurbineVelocity.getContext(data);

        String navigationTemplate = data.getTemplateInfo().getNavigationTemplate();
        String templateName
                = TurbineTemplate.getNavigationTemplateName(navigationTemplate);

View Full Code Here

     */
    public void doBuild(RunData data)
        throws Exception
    {
        // Get the context needed by Velocity.
        Context context = TurbineVelocity.getContext(data);

        // variable for the screen in the layout template
        context.put(TurbineConstants.SCREEN_PLACEHOLDER,
                    new TemplateScreen(data));

        // variable to reference the navigation screen in the layout template
        context.put(TurbineConstants.NAVIGATION_PLACEHOLDER,
                    new TemplateNavigation(data));

        // Grab the layout template set in the VelocityPage.
        // If null, then use the default layout template
        // (done by the TemplateInfo object)
View Full Code Here

     */
    public void doBuild(RunData data)
        throws Exception
    {
        // Get the context needed by Velocity.
        Context context = TurbineVelocity.getContext(data);

        String screenName = data.getScreen();

        log.debug("Loading Screen " + screenName);

        // First, generate the screen and put it in the context so
        // we can grab it the layout template.
        ConcreteElement results =
            ScreenLoader.getInstance().eval(data, screenName);

        String returnValue = (results == null) ? "" : results.toString();

        // variable for the screen in the layout template
        context.put(TurbineConstants.SCREEN_PLACEHOLDER, returnValue);

        // variable to reference the navigation screen in the layout template
        context.put(TurbineConstants.NAVIGATION_PLACEHOLDER,
                    new TemplateNavigation(data));

        // Grab the layout template set in the VelocityPage.
        // If null, then use the default layout template
        // (done by the TemplateInfo object)
View Full Code Here

     */
    public Context getContext(RunData data)
    {
        // Attempt to get it from the data first.  If it doesn't
        // exist, create it and then stuff it into the data.
        Context context = (Context)
            data.getTemplateInfo().getTemplateContext(VelocityService.CONTEXT);

        if (context == null)
        {
            context = getContext();
            context.put(VelocityService.RUNDATA_KEY, data);

            if (pullModelActive)
            {
                // Populate the toolbox with request scope, session scope
                // and persistent scope tools (global tools are already in
View Full Code Here

     * @exception Exception, a generic exception.
     */
    protected void doBuildBeforeAction(RunData data)
        throws Exception
    {
        Context context = TurbineVelocity.getContext(data);
        data.getTemplateInfo()
            .setTemplateContext(VelocityService.CONTEXT, context);
    }
View Full Code Here

TOP

Related Classes of org.apache.velocity.context.Context

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.