Package org.apache.shale.dialog.basic.model

Examples of org.apache.shale.dialog.basic.model.State


        // the logical outcome received from the (current) view state
        Position position = peek();
        if (!START_OUTCOME.equals(outcome)) {
            transition(position, outcome);
        }
        State state = position.getState();
        String viewId = null;
        boolean redirect = false;

        // Advance through states until we again encounter the
        // need to render a view state
        while (true) {

            if (state instanceof ActionState) {
                ActionState astate = (ActionState) state;
                if (log().isTraceEnabled()) {
                    log().trace("-->ActionState(method=" + astate.getMethod() + ")");
                }
                try {
                    MethodBinding mb = context.getApplication().
                      createMethodBinding(astate.getMethod(), ACTION_STATE_SIGNATURE);
                    outcome = (String) mb.invoke(context, ACTION_STATE_PARAMETERS);
                } catch (Exception e) {
                    fireOnException(e);
                }
                transition(position, outcome);
                state = position.getState();
                continue;
            } else if (state instanceof EndState) {
                if (log().isTraceEnabled()) {
                    log().trace("-->EndState()");
                }
                pop();
                position = peek();
                if (position == null) {
                    stop(context);
                } else {
                    transition(position, outcome);
                    state = position.getState();
                    continue;
                }
                viewId = ((EndState) state).getViewId();
                redirect = ((EndState) state).isRedirect();
                break;
            } else if (state instanceof SubdialogState) {
                SubdialogState sstate = (SubdialogState) state;
                if (log().isTraceEnabled()) {
                    log().trace("-->SubdialogState(dialogName="
                              + sstate.getDialogName() + ")");
                }
                Dialog subdialog = (Dialog) dialogs(context).get(sstate.getDialogName());
                if (subdialog == null) {
                    throw new IllegalStateException("Cannot find dialog definition '"
                      + sstate.getDialogName() + "'");
                }
                start(subdialog);
                position = peek();
                state = position.getState();
                continue;
            } else if (state instanceof ViewState) {
                viewId = ((ViewState) state).getViewId();
                redirect = ((ViewState) state).isRedirect();
                if (log().isTraceEnabled()) {
                    log().trace("-->ViewState(viewId="
                              + ((ViewState) state).getViewId()
                              + ",redirect=" + ((ViewState) state).isRedirect()
                              + ")");
                }
                break;
            } else {
                throw new IllegalStateException
                  ("State '" + state.getName()
                   + "' of dialog '" + position.getDialog().getName()
                   + "' is of unknown type '" + state.getClass().getName() + "'");
            }
        }

        // Navigate to the requested view identifier (if any)
        if (viewId == null) {
View Full Code Here


     * @param dialog {@link Dialog} instance to be started and pushed
     */
    private void start(Dialog dialog) {

        // Look up the initial state for the specified dialog
        State state = dialog.findState(dialog.getStart());
        if (state == null) {
            throw new IllegalStateException
              ("Cannot find starting state '"
               + dialog.getStart()
               + "' for dialog '" + dialog.getName() + "'");
        }

        // Construct an appropriate data object for the specified dialog
        Object data = null;
        try {
            data = dialog.getDataClass().newInstance();
        } catch (Exception e) {
            fireOnException(e);
        }

        // Push a Position and corresponding data object to our stacks
        push(new Position(dialog, state, data));

        // inform listeners
        fireOnEntry(state.getName());

    }
View Full Code Here

        // with JSF semantics on null outcomes
        if (outcome == null) {
            return;
        }

        State current = position.getState();
        String fromStateId = current.getName();

        // Select the next state based on the specified outcome
        Transition transition = current.findTransition(outcome);
        if (transition == null) {
            transition = position.getDialog().findTransition(outcome);
        }
        if (transition == null) {
            throw new IllegalStateException
              ("Cannot find transition '" + outcome
               + "' for state '" + fromStateId
               + "' of dialog '" + position.getDialog().getName() + "'");
        }
        State next = position.getDialog().findState(transition.getTarget());
        if (next == null) {
            throw new IllegalStateException
              ("Cannot find state '" + transition.getTarget()
               + "' for dialog '" + position.getDialog().getName() + "'");
        }
        String toStateId = next.getName();
        position.setState(next);

        // We inform listeners at the end, the assumption being that a transition
        // must be an atomic transaction, either all associated callbacks must
        // occur as the application would expect, or none should be initiated
View Full Code Here

TOP

Related Classes of org.apache.shale.dialog.basic.model.State

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.