Articles/JSPIntegration: toolkitIntegration.jsp

File toolkitIntegration.jsp, 1.9 kB (added by Teemu Pontelin, 6 months ago)
Line 
1<%@ page language="java" contentType="text/html; charset=UTF-8"
2    pageEncoding="UTF-8"%>
3
4   
5<script type="text/javascript">
6//<![CDATA[
7     
8    // define the Toolkit application configuration(s)
9        var itmill = {
10                toolkitConfigurations: {
11                        '<%=request.getParameter("appDiv")%>' :{
12                                appUri: '<%=request.getParameter("contextPath") + "/" + request.getParameter("appUri")%>',
13                                pathInfo: '/',
14                                themeUri: '<%=request.getParameter("contextPath")%>/ITMILL/themes/default'
15                        }
16                }
17        };             
18       
19       
20        /**
21         * Simple helper function for sending XMLHttpRequests.
22         */
23        function itmAjax(url, vars, callbackFunction) {
24                var request = window.XMLHttpRequest ?
25                new XMLHttpRequest() :
26                new ActiveXObject("MSXML2.XMLHTTP.3.0");
27             
28                request.open("POST", url, true);
29                request.setRequestHeader("Content-Type",
30                                         "application/x-www-form-urlencoded");
31         
32                request.onreadystatechange = function() {
33                if (request.readyState == 4 && request.status == 200) {
34                        if (request.responseText) {
35                                callbackFunction(request.responseText);
36                        }
37                }
38                };
39                request.send(vars);
40        }
41       
42       
43        /**
44         * Sends an Ajax request to the given uri and calls the
45         * callback function with responseText as a parameter
46         * when the request is ready and the response is available.
47         */
48        function itmSubmitData(uri, callback) {                                                                                                         
49                itmAjax('<%=request.getParameter("contextPath") + "/" + request.getParameter("appUri")%>/' + uri, null, callback);                                                                                     
50                return false;
51        }       
52       
53// ]]>
54</script>
55       
56<script type="text/javascript" src='<%=request.getParameter("contextPath")%>/ITMILL/widgetsets/com.itmill.toolkit.terminal.gwt.DefaultWidgetSet/com.itmill.toolkit.terminal.gwt.DefaultWidgetSet.nocache.js'></script>
57<link rel="stylesheet" type="text/css" href="<%=request.getParameter("contextPath")%>/ITMILL/themes/default/styles.css" />