*/
protected void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
WebAdapter adapter = null;
HttpSession session = request.getSession(true);
XFormsSessionManager sessionManager = getXFormsSessionManager();
XFormsSession xFormsSession = sessionManager.createXFormsSession();
/*
the XFormsSessionManager is kept in the http-session though it is accessible as singleton. Subsequent
servlets should access the manager through the http-session attribute as below to ensure the http-session
is refreshed.
*/
session.setAttribute(XFormsSessionManager.XFORMS_SESSION_MANAGER,sessionManager);
if (LOGGER.isDebugEnabled()) {
printSessionKeys(session);
LOGGER.debug("created XFormsSession with key: " + xFormsSession.getKey());
}
request.setCharacterEncoding("UTF-8");
response.setHeader("Cache-Control","private, no-store, no-cache, must-revalidate");
response.setHeader("Pragma","no-cache");
response.setDateHeader("Expires",-1);
try {
// determine Form to load
String formURI = getRequestURI(request) + request.getParameter(FORM_PARAM_NAME);
if (formURI == null) {
throw new IOException("Resource not found: " + formURI + " not found");
}
String xslFile = request.getParameter(XSL_PARAM_NAME);
String javascriptPresent = request.getParameter(JAVASCRIPT_PARAM_NAME);
String actionURL = null;
if (javascriptPresent != null) {
//do AJAX
adapter = new FluxAdapter();
actionURL = getActionURL(request, response, true);
} else {
//do standard browser support without scripting
adapter = new ServletAdapter();
actionURL = getActionURL(request, response, false);
}
adapter.setXFormsSession(xFormsSession);
//setup Adapter
adapter = setupAdapter(adapter, xFormsSession.getKey(), formURI);
setContextParams(request, adapter);
storeCookies(request, adapter);
storeAcceptLanguage(request, adapter);
adapter.init();
XMLEvent exitEvent = adapter.checkForExitEvent();
if (exitEvent != null) {
handleExit(exitEvent, xFormsSession, session, request, response);
} else {
//todo: review: the following may be substituted with the ViewServlet
response.setContentType(HTML_CONTENT_TYPE);
UIGenerator uiGenerator = createUIGenerator(request, xFormsSession, actionURL, xslFile == null ? xsltDefault : xslFile, javascriptPresent);
uiGenerator.setInput(adapter.getXForms());
uiGenerator.setOutput(response.getOutputStream());
uiGenerator.generate();
//store WebAdapter in XFormsSession
xFormsSession.setAdapter(adapter);