Examples of StateContext


Examples of com.sun.faces.context.StateContext

     * @param struct the component struct.
     */
    private void reapplyDynamicRemove(FacesContext context, ComponentStruct struct) {
        UIComponent child = locateComponentByClientId(context, struct.clientId);
        if (child != null) {
            StateContext stateContext = StateContext.getStateContext(context);
            stateContext.getDynamicComponents().put(struct.clientId, child);
            UIComponent parent = child.getParent();
            parent.getChildren().remove(child);
        }
    }
View Full Code Here

Examples of com.sun.faces.context.StateContext

            /*
             * Are we adding =BACK= in a component that was not in the state,
             * because it was added by the initial buildView and removed by
             * another dynamic action?
             */
            StateContext stateContext = StateContext.getStateContext(context);
            if (child == null) {
                child = stateContext.getDynamicComponents().get(struct.clientId);
            }

            /*
             * Now if we have the child we are going to add it back in.
             */
            if (child != null) {
                if (struct.facetName != null) {
                    parent.getFacets().put(struct.facetName, child);
                } else {
                    int childIndex = -1;
                    if (child.getAttributes().containsKey(DYNAMIC_COMPONENT)) {
                        childIndex = (Integer) child.getAttributes().get(DYNAMIC_COMPONENT);
                    }
                    child.setId(struct.id);
                    if (childIndex >= parent.getChildCount() || childIndex == -1) {
                        parent.getChildren().add(child);
                    } else {
                        parent.getChildren().add(childIndex, child);
                    }
                    child.getClientId();
                }
                child.getAttributes().put(DYNAMIC_COMPONENT, child.getParent().getChildren().indexOf(child));
                stateContext.getDynamicComponents().put(struct.clientId, child);
            }
        }
    }
View Full Code Here

Examples of com.sun.faces.context.StateContext

            LOGGER.finest("FaceletPartialStateManagementStrategy.restoreDynamicRemove");
        }

        UIComponent child = locateComponentByClientId(context, context.getViewRoot(), struct.clientId);
        if (child != null) {
            StateContext stateContext = StateContext.getStateContext(context);
            stateContext.getDynamicComponents().put(struct.clientId, child);
            UIComponent parent = child.getParent();
            parent.getChildren().remove(child);
        }
    }
View Full Code Here

Examples of com.sun.faces.context.StateContext

        if (rawState == null) {
            return null;
        }

        final Map<String, Object> state = (Map<String, Object>) rawState[1];
        final StateContext stateContext = StateContext.getStateContext(context);

        if (state != null) {
            try {
                stateContext.setTrackViewModifications(false);

                context.getAttributes().put(SKIP_ITERATION_HINT, true);
                Set<VisitHint> hints = EnumSet.of(VisitHint.SKIP_ITERATION, VisitHint.EXECUTE_LIFECYCLE);
                VisitContext visitContext = VisitContext.createVisitContext(context, null, hints);
                viewRoot.visitTree(visitContext, new VisitCallback() {

                    public VisitResult visit(VisitContext context, UIComponent target) {
                        VisitResult result = VisitResult.ACCEPT;
                        String cid = target.getClientId(context.getFacesContext());
                        Object stateObj = state.get(cid);
                        if (stateObj != null && !stateContext.componentAddedDynamically(target)) {
                            boolean restoreStateNow = true;
                            if (stateObj instanceof StateHolderSaver) {
                                restoreStateNow = !((StateHolderSaver) stateObj).componentAddedDynamically();
                            }
                            if (restoreStateNow) {
                                try {
                                    target.restoreState(context.getFacesContext(), stateObj);
                                } catch (Exception e) {
                                    String msg =
                                            MessageUtils.getExceptionMessageString(
                                            MessageUtils.PARTIAL_STATE_ERROR_RESTORING_ID,
                                            cid,
                                            e.toString());
                                    throw new FacesException(msg, e);
                                }
                            }
                        }

                        return result;
                    }
                });
                restoreDynamicActions(context, stateContext, state);
            } finally {
                stateContext.setTrackViewModifications(true);
                context.getAttributes().remove(SKIP_ITERATION_HINT);
            }
        } else {
            viewRoot = null;
        }
View Full Code Here

Examples of com.sun.faces.context.StateContext

        }

        Util.checkIdUniqueness(context, viewRoot, new HashSet<String>(viewRoot.getChildCount() << 1));

        final Map<String, Object> stateMap = new HashMap<String, Object>();
        final StateContext stateContext = StateContext.getStateContext(context);

        context.getAttributes().put(SKIP_ITERATION_HINT, true);
        Set<VisitHint> hints = EnumSet.of(VisitHint.SKIP_ITERATION);
        VisitContext visitContext = VisitContext.createVisitContext(context, null, hints);
        final FacesContext finalContext = context;

        try {
            viewRoot.visitTree(visitContext, new VisitCallback() {

                public VisitResult visit(VisitContext context, UIComponent target) {
                    VisitResult result = VisitResult.ACCEPT;
                    Object stateObj;
                    if (!target.isTransient()) {
                        if (stateContext.componentAddedDynamically(target)) {
                            target.getAttributes().put(DYNAMIC_COMPONENT, new Integer(target.getParent().getChildren().indexOf(target)));
                            stateObj = new StateHolderSaver(finalContext, target);
                        } else {
                            stateObj = target.saveState(context.getFacesContext());
                        }
View Full Code Here

Examples of com.sun.faces.context.StateContext

     * @param context the Faces context.
     * @param state the component state.
     */
    private void restoreComponentState(final FacesContext context, final HashMap<String, Object> state) {

        final StateContext stateContext = StateContext.getStateContext(context);
        final UIViewRoot viewRoot = context.getViewRoot();

        try {
            context.getAttributes().put(SKIP_ITERATION_HINT, true);
            Set<VisitHint> hints = EnumSet.of(VisitHint.SKIP_ITERATION);
            VisitContext visitContext = VisitContext.createVisitContext(context, null, hints);

            viewRoot.visitTree(visitContext, new VisitCallback() {

                public VisitResult visit(VisitContext visitContext, UIComponent component) {
                    VisitResult result = VisitResult.ACCEPT;

                    String cid = component.getClientId(context);
                    Object stateObj = state.get(cid);

                    if (stateObj != null && !stateContext.componentAddedDynamically(component)) {
                        boolean restoreStateNow = true;
                        if (stateObj instanceof StateHolderSaver) {
                            restoreStateNow = !((StateHolderSaver) stateObj).componentAddedDynamically();
                        }
                        if (restoreStateNow) {
View Full Code Here

Examples of net.kuujo.copycat.internal.state.StateContext

   * @param protocol The asynchronous protocol.
   * @param config The replica configuration.
   * @param <M> The cluster member type.
   */
  public <M extends Member> Copycat(StateMachine stateMachine, Log log, Cluster<M> cluster, Protocol<M> protocol, CopycatConfig config) {
    this(new StateContext(stateMachine, log, cluster, protocol, config), cluster, config);
  }
View Full Code Here

Examples of org.apache.mina.statemachine.context.StateContext

     * proxy using this method.
     *
     * @param event the {@link Event} to be handled.
     */
    public void handle(Event event) {
        StateContext context = event.getContext();

        synchronized (context) {
            LinkedList<Event> eventQueue = eventQueueThreadLocal.get();
            eventQueue.addLast(event);

            if (processingThreadLocal.get()) {
                /*
                 * This thread is already processing an event. Queue this
                 * event.
                 */
                if (log.isDebugEnabled()) {
                    log.debug("State machine called recursively. Queuing event " + event
                            + " for later processing.");
                }
            } else {
                processingThreadLocal.set(true);
                try {
                    if (context.getCurrentState() == null) {
                        context.setCurrentState(startState);
                    }
                    processEvents(eventQueue);
                } finally {
                    processingThreadLocal.set(false);
                }
View Full Code Here

Examples of org.apache.mina.statemachine.context.StateContext

    }

    private void processEvents(LinkedList<Event> eventQueue) {
        while (!eventQueue.isEmpty()) {
            Event event = eventQueue.removeFirst();
            StateContext context = event.getContext();
            handle(context.getCurrentState(), event);
        }
    }
View Full Code Here

Examples of org.apache.mina.statemachine.context.StateContext

            handle(context.getCurrentState(), event);
        }
    }
   
    private void handle(State state, Event event) {
        StateContext context = event.getContext();

        for (Transition t : state.getTransitions()) {
            if (log.isDebugEnabled()) {
                log.debug("Trying transition " + t);
            }

            try {
                if (t.execute(event)) {
                    if (log.isDebugEnabled()) {
                        log.debug("Transition " + t + " executed successfully.");
                    }
                    setCurrentState(context, t.getNextState());

                    return;
                }
            } catch (BreakAndContinueException bace) {
                if (log.isDebugEnabled()) {
                    log.debug("BreakAndContinueException thrown in "
                            + "transition " + t
                            + ". Continuing with next transition.");
                }
            } catch (BreakAndGotoException bage) {
                State newState = getState(bage.getStateId());

                if (bage.isNow()) {
                    if (log.isDebugEnabled()) {
                        log.debug("BreakAndGotoException thrown in "
                                + "transition " + t + ". Moving to state "
                                + newState.getId() + " now.");
                    }
                    setCurrentState(context, newState);
                    handle(newState, event);
                } else {
                    if (log.isDebugEnabled()) {
                        log.debug("BreakAndGotoException thrown in "
                                + "transition " + t + ". Moving to state "
                                + newState.getId() + " next.");
                    }
                    setCurrentState(context, newState);
                }
                return;
            } catch (BreakAndCallException bace) {
                State newState = getState(bace.getStateId());

                Stack<State> callStack = getCallStack(context);
                State returnTo = bace.getReturnToStateId() != null
                    ? getState(bace.getReturnToStateId())
                    : context.getCurrentState();
                callStack.push(returnTo);

                if (bace.isNow()) {
                    if (log.isDebugEnabled()) {
                        log.debug("BreakAndCallException thrown in "
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.