Package org.chiba.web

Examples of org.chiba.web.WebAdapter


     */
    protected void doPost(HttpServletRequest request,
                          HttpServletResponse response)
            throws ServletException, IOException {
        HttpSession session = request.getSession(true);
        WebAdapter webAdapter = null;

        response.setContentType("text/html");

        String key = request.getParameter("sessionKey");
        try {

            XFormsSessionManager manager = (XFormsSessionManager) session.getAttribute(XFormsSessionManager.XFORMS_SESSION_MANAGER);
            XFormsSession xFormsSession = manager.getXFormsSession(key);

            webAdapter = xFormsSession.getAdapter();
            if (webAdapter == null) {
                throw new ServletException(Config.getInstance().getErrorMessage("session-invalid"));
            }
            ChibaEvent chibaEvent = new DefaultChibaEventImpl();
            chibaEvent.initEvent("http-request", null, request);
            webAdapter.dispatch(chibaEvent);

            boolean isUpload = FileUpload.isMultipartContent(request);

            if (isUpload) {
                ServletOutputStream out = response.getOutputStream();
View Full Code Here


     */
    protected void doGet(HttpServletRequest request,
                         HttpServletResponse response)
            throws ServletException, IOException {
        HttpSession session = request.getSession(true);
        WebAdapter webAdapter = null;

        request.setCharacterEncoding("UTF-8");
        response.setHeader("Cache-Control","private, no-store, no-cache, must-revalidate");
        response.setHeader("Pragma","no-cache");
        response.setHeader("Expires","-1");

        String key = request.getParameter("sessionKey");
        String referer = request.getParameter("referer");
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("handling session: " + key);
            LOGGER.debug("referer: " + referer);
        }
        try {
            XFormsSessionManager manager = (XFormsSessionManager) session.getAttribute(XFormsSessionManager.XFORMS_SESSION_MANAGER);
            XFormsSession xFormsSession = manager.getXFormsSession(key);
            if (xFormsSession == null) {
                LOGGER.info("session does not exist: " + key + " - creating new one");
                response.sendRedirect(response.encodeRedirectURL(request.getContextPath() + "/XFormsServlet?" + referer));

            } else {
                webAdapter = xFormsSession.getAdapter();
                if (webAdapter == null) {
                    throw new ServletException(Config.getInstance().getErrorMessage("session-invalid"));
                }
                response.setContentType(HTML_CONTENT_TYPE);

                UIGenerator uiGenerator = (UIGenerator) xFormsSession.getProperty(XFormsSession.UIGENERATOR);
                uiGenerator.setInput(webAdapter.getXForms());
                uiGenerator.setOutput(response.getOutputStream());
                uiGenerator.generate();

                response.getOutputStream().close();
            }
View Full Code Here

     */
    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);
View Full Code Here

     */
    protected void doPost(HttpServletRequest request,
                          HttpServletResponse response)
            throws ServletException, IOException {
        HttpSession session = request.getSession(true);
        WebAdapter webAdapter = null;
        request.setCharacterEncoding("UTF-8");
        response.setHeader("Cache-Control","private, no-store,  no-cache, must-revalidate");
        response.setHeader("Pragma","no-cache");
        response.setHeader("Expires","-1");

        String key = request.getParameter("sessionKey");
        try {
            XFormsSessionManager manager = (XFormsSessionManager) session.getAttribute(XFormsSessionManager.XFORMS_SESSION_MANAGER);
            XFormsSession xFormsSession = manager.getXFormsSession(key);

            String referer = (String) xFormsSession.getProperty(XFormsSession.REFERER);
            if(LOGGER.isDebugEnabled()){
                LOGGER.debug("referer: " + referer);
            }

            webAdapter = xFormsSession.getAdapter();
            if (webAdapter == null) {
                throw new ServletException(Config.getInstance().getErrorMessage("session-invalid"));
            }
            ChibaEvent chibaEvent = new DefaultChibaEventImpl();
            chibaEvent.initEvent("http-request", null, request);
            webAdapter.dispatch(chibaEvent);

            XMLEvent exitEvent = webAdapter.checkForExitEvent();

            if (exitEvent != null) {
                handleExit(exitEvent, xFormsSession, session, request,response);
            } else {
                response.sendRedirect(response.encodeRedirectURL(request.getContextPath() + "/view?sessionKey=" + xFormsSession.getKey() + "&referer=" + referer));
View Full Code Here

        XFormsSession xFormsSession = manager.getXFormsSession(sessionKey);
        try {

            // don't use getXFormsSession to avoid needless error
            if (xFormsSession == null) return;
            WebAdapter adapter = xFormsSession.getAdapter();
            if (adapter == null) return;
            adapter.shutdown();
        } catch (XFormsException e) {
            LOGGER.warn("FluxFacade close: " + sessionKey, e);
        } finally {
            manager.deleteXFormsSession(sessionKey);
        }
View Full Code Here

TOP

Related Classes of org.chiba.web.WebAdapter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.