org.apache.velocity.context.Context Java Examples

The following examples show how to use org.apache.velocity.context.Context. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VelocityRenderer.java    From opoopress with Apache License 2.0 6 votes vote down vote up
@Override
public String render(Page base, Object rootMap) {
    Context context = convert(rootMap);

    String content = base.getContent();
    String layout = base.getLayout();

    boolean isContentRenderRequired = isRenderRequired(site, base, content);
    boolean isValidLayout = isValidLayout(layout);

    if (isContentRenderRequired) {
        content = renderContent(content, context);
    }

    if (isValidLayout) {
        context.put("content", content);
        content = render("_" + layout + ".vm", context);
    } else {
        //do nothing
        //content = content;
    }

    return content;
}
 
Example #2
Source File: VelocityView.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Merge the template with the context.
 * Can be overridden to customize the behavior.
 * @param template the template to merge
 * @param context the Velocity context to use for rendering
 * @param response servlet response (use this to get the OutputStream or Writer)
 * @throws Exception if thrown by Velocity
 * @see org.apache.velocity.Template#merge
 */
protected void mergeTemplate(
		Template template, Context context, HttpServletResponse response) throws Exception {

	try {
		template.merge(context, response.getWriter());
	}
	catch (MethodInvocationException ex) {
		Throwable cause = ex.getWrappedThrowable();
		throw new NestedServletException(
				"Method invocation failed during rendering of Velocity view with name '" +
				getBeanName() + "': " + ex.getMessage() + "; reference [" + ex.getReferenceName() +
				"], method '" + ex.getMethodName() + "'",
				cause==null ? ex : cause);
	}
}
 
Example #3
Source File: WrappedExceptionTestCase.java    From velocity-engine with Apache License 2.0 6 votes vote down vote up
public void testMethodException() throws Exception
{

    // accumulate a list of invalid references
    Context context = new VelocityContext();
    StringWriter writer = new StringWriter();
    context.put("test",new TestProvider());

    try
    {
        ve.evaluate(context,writer,"test","$test.getThrow()");
        fail ("expected an exception");
    }
    catch (MethodInvocationException E)
    {
        assertEquals(Exception.class,E.getCause().getClass());
        assertEquals("From getThrow()",E.getCause().getMessage());
    }

}
 
Example #4
Source File: RenderTool.java    From velocity-tools with Apache License 2.0 6 votes vote down vote up
protected String internalEval(Context ctx, String vtl) throws Exception
{
    if (vtl == null)
    {
        return null;
    }
    StringWriter sw = new StringWriter();
    boolean success;
    if (engine == null)
    {
        success = Velocity.evaluate(ctx, sw, "RenderTool.eval()", vtl);
    }
    else
    {
        success = engine.evaluate(ctx, sw, "RenderTool.eval()", vtl);
    }
    if (success)
    {
        return sw.toString();
    }
    /* or would it be preferable to return the original? */
    return null;
}
 
Example #5
Source File: VelocityMacroTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void springMacroRequestContextAttributeUsed() {
	final String helperTool = "wrongType";

	VelocityView vv = new VelocityView() {
		@Override
		protected void mergeTemplate(Template template, Context context, HttpServletResponse response) {
			fail();
		}
	};
	vv.setUrl(TEMPLATE_FILE);
	vv.setApplicationContext(wac);
	vv.setExposeSpringMacroHelpers(true);

	Map<String, Object> model = new HashMap<String, Object>();
	model.put(VelocityView.SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE, helperTool);

	try {
		vv.render(model, request, response);
	}
	catch (Exception ex) {
		assertTrue(ex instanceof ServletException);
		assertTrue(ex.getMessage().contains(VelocityView.SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE));
	}
}
 
Example #6
Source File: GenericExporter.java    From RobotBuilder with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Get the context of a robot component with all it's properties filled in.
 *
 * @param comp The component to base the context off of.
 * @return The context, which also inherits from the rootContext
 */
private Context getContext(RobotComponent comp) {
    Context context = new VelocityContext(rootContext);
    final Map<String, String> instructions = componentInstructions.get(comp.getBase().getName());
    context.put("ClassName", instructions.get("ClassName"));
    context.put("Name", comp.getName());
    context.put("Short_Name", comp.getName());
    if (!comp.getSubsystem().isEmpty()) {
        context.put("Subsystem", comp.getSubsystem().substring(0, comp.getSubsystem().length() - 1));
    }
    context.put("Component", comp);
    for (String property : comp.getPropertyKeys()) {
        context.put(property.replace(" ", "_").replace("(", "").replace(")", ""),
                comp.getProperty(property).getValue());
    }
    return context;
}
 
Example #7
Source File: PrintExceptions.java    From velocity-engine with Apache License 2.0 6 votes vote down vote up
/**
 * Render the method exception, and optionally the exception message and stack trace.
 *
 * @param context current context
 * @param claz the class of the object the method is being applied to
 * @param method the method
 * @param e the thrown exception
 * @param info template name and line, column informations
 * @return an object to insert in the page
 */
public Object methodException(Context context, Class claz, String method, Exception e, Info info)
{
    boolean showTemplateInfo = rs.getBoolean(SHOW_TEMPLATE_INFO, false);
    boolean showStackTrace = rs.getBoolean(SHOW_STACK_TRACE,false);

    StringBuilder st = new StringBuilder();
    st.append("Exception while executing method ").append(claz.toString()).append(".").append(method);
    st.append(": ").append(e.getClass().getName()).append(": ").append(e.getMessage());

    if (showTemplateInfo)
    {
        st.append(" at ").append(info.getTemplateName()).append(" (line ").append(info.getLine()).append(", column ").append(info.getColumn()).append(")");
    }
    if (showStackTrace)
    {
        st.append(System.lineSeparator()).append(getStackTrace(e));
    }
    return st.toString();

}
 
Example #8
Source File: VelocityLayoutView.java    From scoold with Apache License 2.0 6 votes vote down vote up
/**
 * Overrides the normal rendering process in order to pre-process the Context, merging it with the screen template
 * into a single value (identified by the value of screenContentKey). The layout template is then merged with the
 * modified Context in the super class.
 */
@Override
protected void doRender(Context context, HttpServletResponse response) throws Exception {
	renderScreenContent(context);

	// Velocity context now includes any mappings that were defined
	// (via #set) in screen content template.
	// The screen template can overrule the layout by doing
	// #set( $layout = "MyLayout.vm" )
	String layoutUrlToUse = (String) context.get(this.layoutKey);
	if (layoutUrlToUse != null) {
		if (logger.isDebugEnabled()) {
			logger.debug("Screen content template has requested layout [" + layoutUrlToUse + "]");
		}
	} else {
		// No explicit layout URL given -> use default layout of this view.
		layoutUrlToUse = this.layoutUrl;
	}

	mergeTemplate(getTemplate(layoutUrlToUse), context, response);
}
 
Example #9
Source File: BpmTypeTaskFormAction.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
public String render(DataObject dataobject, String contentModel, String langCode, RequestContext reqCtx) {
    String renderedEntity;
    try {
        Context velocityContext = new VelocityContext();
        DataObjectWrapper contentWrapper = (DataObjectWrapper) this.getEntityWrapper(dataobject);
        contentWrapper.setRenderingLang(langCode);
        velocityContext.put("data", contentWrapper);
        I18nManagerWrapper i18nWrapper = new I18nManagerWrapper(langCode, this.getI18nManager());
        velocityContext.put("i18n", i18nWrapper);
        SystemInfoWrapper systemInfoWrapper = new SystemInfoWrapper(reqCtx);
        velocityContext.put("info", systemInfoWrapper);
        StringWriter stringWriter = new StringWriter();
        boolean isEvaluated = Velocity.evaluate(velocityContext, stringWriter, "render", contentModel);
        if (!isEvaluated) {
            throw new ApsSystemException("Error rendering DataObject");
        }
        stringWriter.flush();
        renderedEntity = stringWriter.toString();
    } catch (Throwable t) {
        logger.error("Error rendering dataobject", t);
        renderedEntity = "";
    }
    return renderedEntity;
}
 
Example #10
Source File: EvaluateTestCase.java    From velocity-engine with Apache License 2.0 6 votes vote down vote up
/**
 * Test that the event handlers work in #evaluate (since they are
 * attached to the context).  Only need to check one - they all
 * work the same.
 * @throws Exception
 */
public void testEventHandler()
throws Exception
{
    VelocityEngine ve = new VelocityEngine();
    ve.setProperty(RuntimeConstants.EVENTHANDLER_REFERENCEINSERTION, EscapeHtmlReference.class.getName());
    ve.init();

    Context context = new VelocityContext();
    context.put("lt","<");
    context.put("gt",">");
    StringWriter writer = new StringWriter();
    ve.evaluate(context, writer, "test","${lt}test${gt} #evaluate('${lt}test2${gt}')");
    assertEquals("&lt;test&gt; &lt;test2&gt;", writer.toString());

}
 
Example #11
Source File: IncludeErrorTestCase.java    From velocity-engine with Apache License 2.0 6 votes vote down vote up
/**
 * Check that an exception is thrown for the given template
 * @param templateName
 * @param exceptionClass
 * @throws Exception
 */
private void checkException(String templateName,Class exceptionClass)
throws Exception
{
    Context context = new VelocityContext();
    Template template = ve.getTemplate(templateName, "UTF-8");

    try (StringWriter writer = new StringWriter())
    {
        template.merge(context, writer);
        writer.flush();
        fail("File should have thrown an exception");
    }
    catch (Exception E)
    {
        assertTrue(exceptionClass.isAssignableFrom(E.getClass()));
    }

}
 
Example #12
Source File: DefaultVelocityRenderer.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public String render(Object object, String velocityTemplate) {
	String renderedObject = null;
	try {
		Context velocityContext = new VelocityContext();
		velocityContext.put(this.getWrapperContextName(), object);
		StringWriter stringWriter = new StringWriter();
		boolean isEvaluated = Velocity.evaluate(velocityContext, stringWriter, "render", velocityTemplate);
		if (!isEvaluated) {
			throw new ApsSystemException("Rendering error");
		}
		stringWriter.flush();
		renderedObject = stringWriter.toString();
	} catch (Throwable t) {
		_logger.error("Rendering error, class: {} - template: {}", object.getClass().getSimpleName(), velocityTemplate, t);
		//ApsSystemUtils.logThrowable(t, this, "render", "Rendering error");
		renderedObject = "";
	}
	return renderedObject;
}
 
Example #13
Source File: ContextTool.java    From velocity-tools with Apache License 2.0 6 votes vote down vote up
/**
 * Actually do the work of filling in the set of keys
 * for {@link #getKeys} here so subclasses can add keys too.
 * @param keys set to fill with keys
 */
protected void fillKeyset(Set keys)
{
    //NOTE: we don't need to manually add the toolbox keys here
    //      because retrieval of those depends on the context being
    //      a ToolContext which would already give tool keys below

    // recurse down the velocity context collecting keys
    Context velctx = this.context;
    while (velctx != null)
    {
        Object[] ctxKeys = velctx.getKeys();
        keys.addAll(Arrays.asList(ctxKeys));
        if (velctx instanceof AbstractContext)
        {
            velctx = ((AbstractContext)velctx).getChainedContext();
        }
        else
        {
            velctx = null;
        }
    }
}
 
Example #14
Source File: SecureIntrospectionTestCase.java    From velocity-engine with Apache License 2.0 6 votes vote down vote up
private void doTestMethods(VelocityEngine ve, String[] templateStrings, boolean shouldeval)
{
    Context c = new VelocityContext();
    c.put("test", this);

    try
    {
        for (String templateString : templateStrings)
        {
            if (shouldeval && !doesStringEvaluate(ve, c, templateString))
            {
                fail("Should have evaluated: " + templateString);
            }

            if (!shouldeval && doesStringEvaluate(ve, c, templateString))
            {
                fail("Should not have evaluated: " + templateString);
            }
        }

    }
    catch (Exception e)
    {
        fail(e.toString());
    }
}
 
Example #15
Source File: RenderTool.java    From velocity-tools with Apache License 2.0 6 votes vote down vote up
/**
 * Sets the {@link Context} to be used by the {@link #eval(String)}
 * and {@link #recurse(String)} methods.
 * @param context Velocity context
 */
public void setVelocityContext(Context context)
{
    if (!isConfigLocked())
    {
        if (context == null)
        {
            throw new NullPointerException("context must not be null");
        }
        this.context = context;
    }
    else if (this.context != context)
    {
        getLog().error("Attempt was made to set a new context while config was locked.");
    }
}
 
Example #16
Source File: VelocityPortalRenderEngine.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public void render(String template, PortalRenderContext rcontext, Writer out)
		throws Exception
{
	if (log.isTraceEnabled()) {
	   log.trace("Portal trace is on, dumping PortalRenderContext to log:\n" + rcontext.dump());
	}
	
	Context vc = ((VelocityPortalRenderContext) rcontext).getVelocityContext();
	String skin = (String) vc.get("pageCurrentSkin");
	if (skin == null || skin.length() == 0)
	{
		skin = defaultSkin;
	}
	if (!defaultSkin.equals(skin))
	{
		vengine.getTemplate("/vm/" + skin + "/macros.vm");
	}
	vengine.mergeTemplate("/vm/" + skin + "/" + template + ".vm",
			((VelocityPortalRenderContext) rcontext).getVelocityContext(), out);

}
 
Example #17
Source File: InvalidEventHandlerTestCase.java    From velocity-engine with Apache License 2.0 6 votes vote down vote up
public boolean invalidSetMethod(Context context, String leftreference, String rightreference, Info info)
{

    // as a test, make sure this EventHandler is initialized
    if (rs == null)
        fail ("Event handler not initialized!");

    // good object, bad method
    if (leftreference.equals("xx"))
    {
        assertEquals("q1.afternoon()",rightreference);
        throw new RuntimeException("expected exception");
    }
    if (leftreference.equals("yy"))
    {
        assertEquals("$q1",rightreference);
        throw new RuntimeException("expected exception");
    }
    else
    {
        fail("Unexpected left hand side.  " + leftreference);
    }

    return false;
}
 
Example #18
Source File: VelocityLayoutView.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * Overrides the normal rendering process in order to pre-process the Context,
 * merging it with the screen template into a single value (identified by the
 * value of screenContentKey). The layout template is then merged with the
 * modified Context in the super class.
 */
@Override
protected void doRender(Context context, HttpServletResponse response) throws Exception {
	renderScreenContent(context);

	// Velocity context now includes any mappings that were defined
	// (via #set) in screen content template.
	// The screen template can overrule the layout by doing
	// #set( $layout = "MyLayout.vm" )
	String layoutUrlToUse = (String) context.get(this.layoutKey);
	if (layoutUrlToUse != null) {
		if (logger.isDebugEnabled()) {
			logger.debug("Screen content template has requested layout [" + layoutUrlToUse + "]");
		}
	}
	else {
		// No explicit layout URL given -> use default layout of this view.
		layoutUrlToUse = this.layoutUrl;
	}

	mergeTemplate(getTemplate(layoutUrlToUse), context, response);
}
 
Example #19
Source File: VelocityLayoutView.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Overrides the normal rendering process in order to pre-process the Context,
 * merging it with the screen template into a single value (identified by the
 * value of screenContentKey). The layout template is then merged with the
 * modified Context in the super class.
 */
@Override
protected void doRender(Context context, HttpServletResponse response) throws Exception {
	renderScreenContent(context);

	// Velocity context now includes any mappings that were defined
	// (via #set) in screen content template.
	// The screen template can overrule the layout by doing
	// #set( $layout = "MyLayout.vm" )
	String layoutUrlToUse = (String) context.get(this.layoutKey);
	if (layoutUrlToUse != null) {
		if (logger.isDebugEnabled()) {
			logger.debug("Screen content template has requested layout [" + layoutUrlToUse + "]");
		}
	}
	else {
		// No explicit layout URL given -> use default layout of this view.
		layoutUrlToUse = this.layoutUrl;
	}

	mergeTemplate(getTemplate(layoutUrlToUse), context, response);
}
 
Example #20
Source File: EventHandlingTestCase.java    From velocity-engine with Apache License 2.0 5 votes vote down vote up
/**
 *  Event handler for when a reference is inserted into the output stream.
 */
public Object referenceInsert( Context context, String reference, Object value  )
{
    // as a test, make sure this EventHandler is initialized
    if (rs == null)
        fail ("Event handler not initialized!");


    /*
     *  if we have a value
     *  return a known value
     */
    String s = null;

    if( value != null )
    {
        s = REFERENCE_VALUE;
    }
    else
    {
        /*
         * we only want to deal with $floobie - anything
         *  else we let go
         */
        if ( reference.equals("$floobie") )
        {
            s = NO_REFERENCE_VALUE;
        }
    }
    return s;
}
 
Example #21
Source File: VelocityLoginRenderEngine.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public void render(String template, LoginRenderContext rcontext, Writer out)
		throws Exception {
	Context vc = ((VelocityLoginRenderContext) rcontext).getVelocityContext();
	String skin = (String) vc.get("pageCurrentSkin");
	if (skin == null || skin.length() == 0)
	{
		skin = "defaultskin";
	}
	if (!"defaultskin".equals(skin))
	{
		vengine.getTemplate("/vm/" + skin + "/macros.vm");
	}
	vengine.mergeTemplate("/vm/" + skin + "/" + template + ".vm",
			((VelocityLoginRenderContext) rcontext).getVelocityContext(), out);
}
 
Example #22
Source File: VelocityLayoutView.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * The resulting context contains any mappings from render, plus screen content.
 */
private void renderScreenContent(Context velocityContext) throws Exception {
	if (logger.isDebugEnabled()) {
		logger.debug("Rendering screen content template [" + getUrl() + "]");
	}

	StringWriter sw = new StringWriter();
	Template screenContentTemplate = getTemplate(getUrl());
	screenContentTemplate.merge(velocityContext, sw);

	// Put rendered content into Velocity context.
	velocityContext.put(this.screenContentKey, sw.toString());
}
 
Example #23
Source File: CommentsTestCase.java    From velocity-engine with Apache License 2.0 5 votes vote down vote up
/**
 * Test combined comments
 * @throws Exception
 */
public void testCombined()
throws Exception
{
    VelocityEngine ve = new VelocityEngine();
    ve.init();

    Context context = new VelocityContext();
    StringWriter writer = new StringWriter();
    ve.evaluate(context, writer, "test","test\r\n## #* *# ${user \r\nabc");
    assertEquals("test\r\nabc", writer.toString());

}
 
Example #24
Source File: VelocityLoginRenderEngine.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public void render(String template, LoginRenderContext rcontext, Writer out)
		throws Exception {
	Context vc = ((VelocityLoginRenderContext) rcontext).getVelocityContext();
	String skin = (String) vc.get("pageCurrentSkin");
	if (skin == null || skin.length() == 0)
	{
		skin = "defaultskin";
	}
	if (!"defaultskin".equals(skin))
	{
		vengine.getTemplate("/vm/" + skin + "/macros.vm");
	}
	vengine.mergeTemplate("/vm/" + skin + "/" + template + ".vm",
			((VelocityLoginRenderContext) rcontext).getVelocityContext(), out);
}
 
Example #25
Source File: ReportInvalidReferences.java    From velocity-engine with Apache License 2.0 5 votes vote down vote up
/**
 * Collect the error and/or throw an exception, depending on configuration.
 *
 * @param context the context when the reference was found invalid
 * @param reference complete invalid reference
 * @param object the object referred to, or null if not found
 * @param method the property name from the reference
 * @param info contains template, line, column details
 * @return always returns null
 * @throws ParseErrorException
 */
public Object invalidMethod(Context context, String reference, Object object,
        String method, Info info)
{
    if (reference == null)
    {
        reportInvalidReference(object.getClass().getName() + "." + method, info);
    }
    else
    {
        reportInvalidReference(reference, info);
    }
    return null;
}
 
Example #26
Source File: EventExample.java    From velocity-engine with Apache License 2.0 5 votes vote down vote up
/**
 *  Event handler for when a reference is inserted into the output stream.
 */
public Object referenceInsert( Context context, String reference, Object value  )
{
    /*
     *  if we have a value
     *  lets decorate the reference with emoticons
     */

    String s = null;

    if( value != null )
    {
        s = " ;) " + value.toString() + " :-)";
    }
    else
    {
        /*
         * we only want to deal with $floobie - anything
         *  else we let go
         */
        if ( reference.equals("floobie") )
        {
            s = "<no floobie value>";
        }
    }
    return s;
}
 
Example #27
Source File: AbstractDropboxBaseController.java    From olat with Apache License 2.0 5 votes vote down vote up
private String getConfirmation(final UserRequest ureq, final String filename) {
    // grab standard text
    final String confirmation = translate("conf.stdtext");
    config.set(TACourseNode.CONF_DROPBOX_CONFIRMATION, confirmation);

    final Context c = new VelocityContext();
    final Identity identity = ureq.getIdentity();
    c.put("login", identity.getName());
    c.put("first", getUserService().getUserProperty(identity.getUser(), UserConstants.FIRSTNAME, getLocale()));
    c.put("last", getUserService().getUserProperty(identity.getUser(), UserConstants.LASTNAME, getLocale()));
    c.put("email", getUserService().getUserProperty(identity.getUser(), UserConstants.EMAIL, getLocale()));
    c.put("filename", filename);
    final Date now = new Date();
    final 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
    final AssessableCourseNode acn = (AssessableCourseNode) node;
    acn.incrementUserAttempts(userCourseEnv);

    // log entry for this file
    final UserNodeAuditManager am = userCourseEnv.getCourseEnvironment().getAuditManager();
    am.appendToUserNodeLog(node, identity, identity, "FILE UPLOADED: " + filename);
    VelocityHelper vh = (VelocityHelper) CoreSpringFactory.getBean(VelocityHelper.class);
    return vh.evaluateVTL(confirmation, c);
}
 
Example #28
Source File: VelocityHelper.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public static boolean mergeTemplate(VelocityEngine vengine, String vTemplate,
		Context context, PrintWriter out)
{
	boolean retval = false;
	try {
		vengine.mergeTemplate(vTemplate, context, out);
		retval = true;
	}

	finally
	{
		if ( retval == false) log.warn("Unable to process Template - {}", vTemplate);
		return retval;
	}
}
 
Example #29
Source File: DirectoryServlet.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
protected void doGet(HttpServletRequest request, HttpServletResponse response) 
		throws ServletException, IOException {
	D2RServer server = D2RServer.fromServletContext(getServletContext());
	server.checkMappingFileChanged();
	if (request.getPathInfo() == null) {
		response.sendError(404);
		return;
	}
	String classMapName = request.getPathInfo().substring(1);
	int limit = server.getConfig().getLimitPerClassMap();
	Model resourceList = server.getMapping().getResourceCollection(classMapName).getInventoryModel(limit);
	if (resourceList == null) {
		response.sendError(404, "Sorry, class map '" + classMapName + "' not found.");
		return;
	}
	Map<String,String> resources = new TreeMap<String,String>();
	ResIterator subjects = resourceList.listSubjects();
	while (subjects.hasNext()) {
		Resource resource = subjects.nextResource();
		if (!resource.isURIResource()) {
			continue;
		}
		String uri = resource.getURI();
		Statement labelStmt = PageServlet.getBestLabel(resource);
		String label = (labelStmt == null) ? resource.getURI() : labelStmt.getString();
		resources.put(uri, label);
	}
	Map<String,String> classMapLinks = new TreeMap<String,String>();
	for (String name: server.getMapping().getResourceCollectionNames()) {
		classMapLinks.put(name, server.baseURI() + "directory/" + name);
	}
	VelocityWrapper velocity = new VelocityWrapper(this, request, response);
	Context context = velocity.getContext();
	context.put("rdf_link", server.baseURI() + "all/" + classMapName);
	context.put("classmap", classMapName);
	context.put("classmap_links", classMapLinks);
	context.put("resources", resources);
	context.put("limit_per_class_map", server.getConfig().getLimitPerClassMap());
	velocity.mergeTemplateXHTML("directory_page.vm");
}
 
Example #30
Source File: BuiltInEventHandlerTestCase.java    From velocity-engine with Apache License 2.0 5 votes vote down vote up
private Context newEscapeContext()
{
    Context context = new VelocityContext();
    context.put("test1","Jimmy's <b>pizza</b>");
    context.put("test1_js","Jimmy's <b>pizza</b>");
    context.put("test1_js_test","Jimmy's <b>pizza</b>");
    return context;
}