@HEAD
@OPTIONS
public Object augment() {
Object o = next();
ThreadContext c = ThreadContext.get();
RequestManager manager = c.getRequestManager();
Response r = getResponse();
if (o instanceof XML) {
// log.debug("Augmenting: " + r.getETag());
XML xml = (XML) o;
String home = manager.getWebSiteURL(c.getServletRequest()
.isSecure());
xml = xml
.prependContent(
"//xhtml:head",
XML.parseTemplate(
"<script type=\"text/javascript\" src=[JWIG]></script>")
.plug("JWIG", manager.makeURL("jwigJS")));
xml = xml
.prependContent(
"//xhtml:body", //It is safe to set a constant id given that only one body may exist
XML.parseTemplate("<div id=\"noscript\" style=\"color:red\">" +
"[ This web application uses JavaScript, which is not enabled in your browser - "
+ "for full functionality, use a browser that supports JavaScript ]</div>" +
"<script type=\"text/javascript\"> " +
"document.getElementById(\"noscript\").style.display = \"none\";" +
"</script>"));
xml = xml.appendContent("//xhtml:body",
XML.parseTemplate(
"<script type=\"text/javascript\">"
+ "jwig.run('<[HOME]>');" + "</script>")
.plug("HOME", home));
xml = xml.appendContent("//xhtml:body",
XML.parseTemplate("<script type=\"text/javascript\">"
+ "jwig.submitHandlerData = <[SUB]> ;" + "</script>").plug("SUB",
generateSubmitHandlerData(r)));
if (auto_refresh_sessions) {
Set<Session> sessions = r.getSessions();
if (sessions != null && sessions.size() > 0) {
int minutes = 0;
for (Session s : sessions) {
int min = s.getMinutes();
if (minutes < min || minutes == 0) {
minutes = min;
}
}
Object[] ss = { sessions.toArray() };
xml = xml
.appendContent(
"//xhtml:head",
XML.parseTemplate(
"<script type=\"text/javascript\">"
+ "jwig.startRefreshSessions('<[REFRESH_URL]>',<[MINUTES]>);"
+ "</script>")
.plug("REFRESH_URL",
manager.makeURL(
"touchSessions", ss)
.toString())
.plug("MINUTES", minutes - 1));
}
}