Created
June 11, 2011 11:47
-
-
Save rbackhouse/1020491 to your computer and use it in GitHub Desktop.
Example JSP showing calling the JS Optimizer API
This file contains 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.JSAnalysisData" %> | |
<script type="text/javascript"> | |
djConfig = { | |
isDebug: false, | |
usePlainJson: true, | |
parseOnLoad: true, | |
baseUrl: "<%=request.getContextPath()%>/dojo/", | |
locale: "<%=request.getLocale().toString().toLowerCase().replace('_', '-')%>", | |
localizationComplete: true | |
}; | |
</script> | |
<% | |
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"); | |
} | |
JSAnalysisData widgetAnalysisData = jsOptimizer.getAnalysisData(new String[] {"dijit._Widget"}); | |
JSAnalysisData calendarAnalysisData = jsOptimizer.getAnalysisData(new String[] {"dijit.Calendar"}, new JSAnalysisData[]{widgetAnalysisData}); | |
JSAnalysisData analysisData = jsOptimizer.getAnalysisData(new String[] {"test.PersonGrid"}, new JSAnalysisData[]{calendarAnalysisData, widgetAnalysisData}); | |
String widgetUrl = request.getContextPath() +"/_javascript?modules=dijit._Widget&version="+widgetAnalysisData.getChecksum()+"&locale="+request.getLocale(); | |
%> | |
<script type="text/javascript" src="<%=widgetUrl%>"/></script> | |
<% | |
String calendarUrl = request.getContextPath() +"/_javascript?modules=dijit.Calendar&version="+calendarAnalysisData.getChecksum()+"&locale="+request.getLocale()+"&writeBootstrap=false&exclude="+widgetAnalysisData.getKey(); | |
%> | |
<script type="text/javascript" src="<%=calendarUrl%>"/></script> | |
<% | |
String url = request.getContextPath() +"/_javascript?modules=test.PersonGrid&version="+analysisData.getChecksum()+"&locale="+request.getLocale()+"&writeBootstrap=false&exclude="+calendarAnalysisData.getKey()+","+widgetAnalysisData.getKey(); | |
%> | |
<script type="text/javascript" src="<%=url%>"/></script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment