protected void processAjaxRequest( Form form, HttpServletRequest request, HttpServletResponse response) throws IOException { AjaxResponse ajaxResponse = new AjaxResponse(response); if (form != null) { form.getFormContext().setWriter(response.getWriter()); form.setFormListener(ajaxResponse); if (isEventRequest(request)) { processEventRequest(form, request); } else { processForm(form, request); } form.setFormListener(null); } else { String message = messageSource.getMessage( "error.sessionExpired", null, "Your session has expired", RequestContextUtils.getLocale(request)); ajaxResponse.alert(message); } ajaxResponse.close(); }
protected void processEventRequest(Form form, HttpServletRequest request) { String id = request.getParameter("event.source"); log.debug("Processing AJAX request triggered by element " + id); Element element = form.getElementById(id); JavaScriptEvent event = new JavaScriptEvent(request); if (element instanceof JavaScriptEventAdapter) { JavaScriptEventAdapter ea = (JavaScriptEventAdapter) element; ea.handleJavaScriptEvent(event); } else { log.error("Element does not implement JavaScriptEventAdapter"); } }