Created
October 23, 2011 15:38
-
-
Save rbackhouse/1307484 to your computer and use it in GitHub Desktop.
JSP Example using the Zazl AMD Optimizer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ page import="org.dojotoolkit.optimizer.JSOptimizer" %> | |
<%@ page import="org.dojotoolkit.optimizer.servlet.JSURLGenerator" %> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
<style type="text/css"> | |
@import "lib/dojo/resources/dojo.css"; | |
@import "lib/dijit/themes/claro/claro.css"; | |
</style> | |
<% | |
JSOptimizer jsOptimizer = (JSOptimizer)pageContext.getServletContext().getAttribute("org.dojotoolkit.optimizer.JSOptimizer"); | |
if (jsOptimizer == null) { | |
throw new JspException("A JSOptimizer has not been loaded into the servlet context"); | |
} | |
JSURLGenerator urlGenerator = new JSURLGenerator(jsOptimizer, request.getLocale(), request.getContextPath()); | |
%> | |
<script type="text/javascript" src="<%=urlGenerator.generateURL("amdtest/Calendar")%>"/></script> | |
<script type="text/javascript"> | |
var dojoConfig = { | |
locale : "<%=request.getLocale().toString().toLowerCase().replace('_', '-')%>", | |
has:{ | |
"dojo-1x-base":1 | |
} | |
}; | |
zazl({ | |
paths: { | |
amdtest: "lib/amdtest" | |
}, | |
packages: [ | |
{ | |
name: 'dojo', | |
location: 'lib/dojo', | |
main:'main' | |
}, | |
{ | |
name: 'dijit', | |
location: 'lib/dijit', | |
main:'main' | |
}, | |
{ | |
name: 'dojox', | |
location: 'lib/dojox', | |
main:'main' | |
} | |
] | |
}, | |
["amdtest/Calendar"], | |
function(calendar) { | |
console.log("done"); | |
}); | |
</script> | |
</head> | |
<body class="claro"> | |
<div id="calendarNode"></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment