<%@ 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"%>
<% 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 model = new HashMap(); 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; } %> Ta bort