Revision: 49823
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at July 30, 2011 23:54 by laurenceosx
Initial Code
package com.vaadin.terminal.gwt.server;
import javax.servlet.http.HttpServletRequest;
/**
* Created by IntelliJ IDEA.
* User: laurence
* Date: Jul 29, 2011
* Time: 8:06:44 PM
*
* com.vaadin.terminal.gwt.server.ApplicationServlet2
*
* Needed to create this for Dojo to work with Vaadin.
*
* This looks for a file named header.inc.htm in
* dir getServletContext().getRealPath(".");
* and injects it into a vaadin page response (providing it exists)
*
* You must change your vaadin servlet name in web.xml
* from: com.vaadin.terminal.gwt.server.ApplicationServlet
* to: com.vaadin.terminal.gwt.server.ApplicationServlet2
*
* Also noticed the inline dojo method script button onClick events
* do not work in Vaadin custom layout templates
* but the new dojo html5 way of handling button clicks does work
*
* Also had to use dojo to update the body class to the tundra style
*
<script type="text/javascript">
// <![CDATA[
dojo.ready( function() { dojo.addClass( dojo.body() , "tundra"); } );
// ]]>
</script>
*
*
*/
public class ApplicationServlet2
extends com.vaadin.terminal.gwt.server.ApplicationServlet {
public ApplicationServlet2() {
super();
}
def String doTemplate(String aStrTemplate, Map aBindingMap) {
def engine = new groovy.text.SimpleTemplateEngine();
def template = engine.createTemplate(aStrTemplate).make(aBindingMap);
return template.toString();
}
def writeDebugString1( BufferedWriter a_page, String a_path ) {
// ij ide """ syntax highlighting workaround
def sDebug1_templ = '''
<!--
header.inc.htm
web path: .
file path: ${a_path}
-->
'''.trim();
def sDebug1 = doTemplate(sDebug1_templ, ["a_path": a_path] as Map);
a_page.write(sDebug1 as String);
}
@Override
protected void writeAjaxPageHtmlHeadStart(BufferedWriter page,
HttpServletRequest request)
throws IOException {
super.writeAjaxPageHtmlHeadStart(page, request);
def sPath1 = this.getServletContext().getRealPath(".");
def sPath2 = new File(sPath1).getCanonicalPath();
def sPath3 = "${sPath2}${File.separator}header.inc.htm";
def fo = new File(sPath3);
page.write("\n<!-- header.inc.htm beg -->\n");
writeDebugString1( page, sPath3 );
if (fo.exists()) {
def sHeaderInc = fo.text;
page.write(sHeaderInc as String);
}
page.write("\n<!-- header.inc.htm end -->\n\n");
}
//
}
Initial URL
Initial Description
Initial Title
Use Dojo with Vaadin / Inject external file into head block of Vaadin page response
Initial Tags
Initial Language
Groovy