All pastes #263437 Raw Edit

Miscellany

public text v1 · immutable
·published 2006-12-01 15:24 UTC
rendered paste body
<%@ tag import="net.unikum.model.notification.PersonalNotification"%>
<%@ tag import="org.apache.velocity.app.VelocityEngine"%>
<%@ tag import="org.springframework.ui.velocity.VelocityEngineUtils"%>
<%@ tag import="net.unikum.webapp.taglib.UnikumFunctions"%>
<%@ tag import="java.util.Map"%>
<%@ tag import="java.util.HashMap"%>
<%@ tag import="org.springframework.ui.velocity.VelocityEngineFactory"%>
<%@ tag import="java.util.Properties"%>
<%@ tag import="org.springframework.ui.velocity.VelocityEngineFactoryBean"%>
<%@ tag body-content="empty" pageEncoding="UTF-8" %>
<%@ attribute name="notification" type="net.unikum.model.notification.PersonalNotification" required="true" %>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="unik" tagdir="/WEB-INF/tags"%>

 <div class="minimessage">
    <%
        try {
            PersonalNotification pn = (PersonalNotification) jspContext.getAttribute("notification");
            String type = pn.getType().substring(0, 1).toUpperCase()+ pn.getType().substring(1);
            String templateName = "notificationtemplates/application/"+pn.getEntityClass().getSimpleName()+type+".vm";
            Map<String, Object> model = new HashMap<String, Object>();
            model.putAll(pn.getModel());
            model.put("id", pn.getEntityId());
            model.put("saxonUtil", new UnikumFunctions());
            Properties prp = new Properties();
            prp.setProperty("resource.loader", "class");
            prp.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
            VelocityEngineFactoryBean fb = new VelocityEngineFactoryBean();
            fb.setVelocityProperties(prp);
            VelocityEngineUtils.mergeTemplate(fb.createVelocityEngine(), templateName, "UTF-8", model, out);
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
    %>
    <a href="javascript:alert('nip')"><img src="images/icons/delete.gif" alt="Ta bort"/></a>
 </div>