NIHVIVO-151. Display the DisplayMessage on the next page loaded. Clear the message from the session. Added sample display markup to page templates.

This commit is contained in:
rjy7 2010-11-16 19:09:03 +00:00
parent 02864178f5
commit 174c548b27
3 changed files with 25 additions and 9 deletions

View file

@ -59,14 +59,19 @@ public class DisplayMessage {
* If there is no message, return the empty string. * If there is no message, return the empty string.
*/ */
public static String getMessageAndClear(HttpSession session) { public static String getMessageAndClear(HttpSession session) {
String message = NO_MESSAGE;
if (session != null) { if (session != null) {
Object message = session.getAttribute(ATTRIBUTE_NAME); Object sessionMessage = session.getAttribute(ATTRIBUTE_NAME);
if (message instanceof String) { if (sessionMessage != null) {
log.debug("Get message: '" + message + "'"); if (sessionMessage instanceof String) {
return (String) message; log.debug("Get message: '" + sessionMessage + "'");
message = (String) sessionMessage;
}
session.removeAttribute(ATTRIBUTE_NAME);
} else {
log.debug("Get no message.");
} }
} }
log.debug("Get no message."); return message;
return NO_MESSAGE;
} }
} }

View file

@ -21,6 +21,7 @@ import com.hp.hpl.jena.rdf.model.Model;
import edu.cornell.mannlib.vedit.beans.LoginStatusBean; import edu.cornell.mannlib.vedit.beans.LoginStatusBean;
import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean; import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean;
import edu.cornell.mannlib.vitro.webapp.beans.DisplayMessage;
import edu.cornell.mannlib.vitro.webapp.beans.Portal; import edu.cornell.mannlib.vitro.webapp.beans.Portal;
import edu.cornell.mannlib.vitro.webapp.config.RevisionInfoBean; import edu.cornell.mannlib.vitro.webapp.config.RevisionInfoBean;
import edu.cornell.mannlib.vitro.webapp.controller.ContactMailServlet; import edu.cornell.mannlib.vitro.webapp.controller.ContactMailServlet;
@ -35,7 +36,6 @@ import edu.cornell.mannlib.vitro.webapp.web.templatemodels.files.Scripts;
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.files.Stylesheets; import edu.cornell.mannlib.vitro.webapp.web.templatemodels.files.Stylesheets;
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.menu.TabMenu; import edu.cornell.mannlib.vitro.webapp.web.templatemodels.menu.TabMenu;
import freemarker.ext.beans.BeansWrapper; import freemarker.ext.beans.BeansWrapper;
import freemarker.ext.servlet.AllHttpScopesHashModel;
import freemarker.template.Configuration; import freemarker.template.Configuration;
import freemarker.template.DefaultObjectWrapper; import freemarker.template.DefaultObjectWrapper;
import freemarker.template.TemplateModel; import freemarker.template.TemplateModel;
@ -397,6 +397,11 @@ public class FreemarkerHttpServlet extends VitroHttpServlet {
if ( ! StringUtils.isEmpty(bannerImage)) { if ( ! StringUtils.isEmpty(bannerImage)) {
map.put("bannerImage", UrlBuilder.getUrl(themeDir + "site_icons/" + bannerImage)); map.put("bannerImage", UrlBuilder.getUrl(themeDir + "site_icons/" + bannerImage));
} }
String flashMessage = DisplayMessage.getMessageAndClear(vreq);
if (! flashMessage.isEmpty()) {
map.put("flash", flashMessage);
}
return map; return map;
} }

View file

@ -21,7 +21,13 @@
<hr class="hidden" /> <hr class="hidden" />
<div id="contentwrap"> <div id="contentwrap">
<#if flash?has_content>
<div id="flash-message">
${flash}
</div>
</#if>
<div id="content"> <div id="content">
${body} ${body}
</div> <!-- content --> </div> <!-- content -->