Package com.nexirius.framework.htmlview.application

Examples of com.nexirius.framework.htmlview.application.HTMLApplication


     * @param response
     * @throws ServletException
     * @throws IOException
     */
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        HTMLApplication application = getHTMLApplication();
        HttpSession session = application.getSession(request);
        String sessionVariableName = getSessionVariableName(application);
        HTMLSessionVariable sessionVariable = (HTMLSessionVariable) session.getAttribute(sessionVariableName);

        try {

            if (sessionVariable == null) {
                htmlApplication.preInit();
                sessionVariable = application.init();
                FWLog.debug("NEW SESSION CREATED");
                session.setAttribute(sessionVariableName, sessionVariable);
                htmlApplication.postInit(sessionVariable);
            }

            synchronized (sessionVariable) {
                sessionVariable.clearSelectedChildren();
                sessionVariable.init(request, response);

                HTMLState oldState = null;
                HTMLState actState = null;

                oldState = sessionVariable.getActState();

                if (sessionVariable.getEvent() != null && sessionVariable.getEvent().equals(BackButtonHTMLFunction.BACK_EVENT)) {
                    oldState = sessionVariable.getActState();
                    sessionVariable.goBackOneState();
                } else {

                    if (sessionVariable.getState() != null && sessionVariable.getState().length() > 0 && !sessionVariable.getState().equals(oldState.getName()))
                    {
                        // try to walk back to the requested state
                        oldState = sessionVariable.goBackwardState();
                    } else if (sessionVariable.getState() == null) {
                        sessionVariable.resetStateMachine();
                        oldState = sessionVariable.getActState();
                    }
                }

                FWLog.debug("OLD STATE = " + oldState.getName());

                HTMLCommand command = application.getHTMLCommand(oldState.getName(), sessionVariable.getEvent());
                boolean doSwitchState = true;

                if (command == null) {
                    // check whether there is a default command registered with no specifc start state
                    command = application.getDefaultHTMLCommand(sessionVariable.getEvent());
                }

                if (command != null) {
                    if (command.requiresMapping()) {
                        DataModel actModel = sessionVariable.getActState().getModel();

                        if (actModel != null) {
                            mapRequestParametersToModel(request, actModel);
                        }
                    }

                    try {
                        FWLog.debug("execute command " + command.getClass());
                        doSwitchState = command.execute(sessionVariable);

                        // do not try to create a response, if the command handles the response itself
                        if (command.handlesResponse()) {
                            return;
                        }
                    } catch (Exception e) {
                        application.handleException(sessionVariable, e);
                    }
                }

                if (doSwitchState) {
                    HTMLTransition defaultTransition = application.getDefaultHTMLTransition(sessionVariable.getEvent());
                    HTMLState targetState = defaultTransition == null ? null : defaultTransition.getTargetState();

                    if (BackButtonHTMLFunction.BACK_EVENT.equals(sessionVariable.getEvent())) {
                        targetState = sessionVariable.getActState();
                        FWLog.debug("targetState = " + targetState.getName());
View Full Code Here

TOP

Related Classes of com.nexirius.framework.htmlview.application.HTMLApplication

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.