Package com.sun.faces.util

Examples of com.sun.faces.util.ComponentStruct


        List<Object> savedActions = (List<Object>) stateMap.get(DYNAMIC_ACTIONS);
        List<ComponentStruct> actions = stateContext.getDynamicActions();

        if (savedActions != null && !savedActions.isEmpty()) {
            for (Object object : savedActions) {
                ComponentStruct action = new ComponentStruct();
                action.restoreState(context, object);
                if (ComponentStruct.ADD.equals(action.action)) {
                    restoreDynamicAdd(context, stateMap, action);
                }
                if (ComponentStruct.REMOVE.equals(action.action)) {
                    restoreDynamicRemove(context, action);
View Full Code Here


        List<Object> savedActions = (List<Object>) viewRoot.getAttributes().get(DYNAMIC_ACTIONS);
        List<ComponentStruct> actions = stateContext.getDynamicActions();

        if (savedActions != null && !savedActions.isEmpty()) {
            for (Object object : savedActions) {
                ComponentStruct action = new ComponentStruct();
                action.restoreState(context, object);
                if (ComponentStruct.ADD.equals(action.action)) {
                    restoreDynamicAdd(context, state, action);
                }
                if (ComponentStruct.REMOVE.equals(action.action)) {
                    restoreDynamicRemove(context, action);
View Full Code Here

                Object restoredAddList[] = (Object[]) state.get(CLIENTIDS_TO_ADD_NAME);
                if (restoredAddList != null && restoredAddList.length > 0) {
                    // Restore the list of added components
                    List<ComponentStruct> addList = new ArrayList<ComponentStruct>(restoredAddList.length);
                    for (Object aRestoredAddList : restoredAddList) {
                        ComponentStruct cur = new ComponentStruct();
                        cur.restoreState(context, aRestoredAddList);
                        addList.add(cur);
                    }
                    // restore the components themselves
                    for (ComponentStruct cur : addList) {
                        final ComponentStruct finalCur = cur;
                        // Find the parent

                        viewRoot.visitTree(visitContext, new VisitCallback() {
                            public VisitResult visit(VisitContext context, UIComponent target) {
                                VisitResult result = VisitResult.ACCEPT;
                                if (finalCur.parentClientId.equals(target.getClientId(context.getFacesContext()))) {
                                    StateHolderSaver saver = (StateHolderSaver) state.get(finalCur.clientId);
                                    UIComponent toAdd = (UIComponent) saver.restore(context.getFacesContext());
                                    int idx = finalCur.indexOfChildInParent;
                                    if (idx == -1) {
                                        // add facet to the parent
                                        target.getFacets().put(finalCur.facetName, toAdd);
                                    } else {
                                        // add the child to the parent at correct index
                                        try {
                                            target.getChildren().add(finalCur.indexOfChildInParent, toAdd);
                                        } catch (IndexOutOfBoundsException ioobe) {
                                            // the indexing within the parent list is off during the restore.
                                                // This is most likely due to a transient component added during
                                                // RENDER_REPONSE phase.
                                                if (LOGGER.isLoggable(Level.FINE)) {
                                                    LOGGER.log(Level.FINE,
                                                            "Unable to insert child with client ID {0} into parent with client ID {1} into list at index {2}.",
                                                            new Object[]{finalCur.clientId,
                                                                finalCur.parentClientId,
                                                                finalCur.indexOfChildInParent});
                                                }
                                                target.getChildren().add(toAdd);
                                        }


                                    }

                                   // Add back to dynamic adds list
                                    Map<String, ComponentStruct> dynamicAdds = stateContext.getDynamicAdds();
                                    assert(null != dynamicAdds);
                                    String clientId = toAdd.getClientId(context.getFacesContext());
                                    if (!dynamicAdds.containsKey(clientId)) {
                                        ComponentStruct toAddCS = new ComponentStruct();
                                        toAddCS.absorbComponent(context.getFacesContext(), toAdd);
                                        dynamicAdds.put(clientId, toAddCS);
                                    }
                                }

                                return result;
View Full Code Here

                parent = parent.getParent();
            }

            parent = added.getParent();
            StateContext.this.incrementDynamicChildCount(parent);
            ComponentStruct toAdd = new ComponentStruct();
            toAdd.absorbComponent(context, added);

            if (dynamicRemoves != null) {
                dynamicRemoves.remove(toAdd.clientId);
            }
            added.getAttributes().put(DYNAMIC_COMPONENT, new Integer(toAdd.indexOfChildInParent));
View Full Code Here

        List<Object> savedActions = (List<Object>) stateMap.get(DYNAMIC_ACTIONS);
        List<ComponentStruct> actions = stateContext.getDynamicActions();

        if (savedActions != null && !savedActions.isEmpty()) {
            for (Object object : savedActions) {
                ComponentStruct action = new ComponentStruct();
                action.restoreState(context, object);
                if (ComponentStruct.ADD.equals(action.action)) {
                    restoreDynamicAdd(context, stateMap, action);
                }
                if (ComponentStruct.REMOVE.equals(action.action)) {
                    restoreDynamicRemove(context, action);
View Full Code Here

        List<Object> savedActions = (List<Object>) viewRoot.getAttributes().get(DYNAMIC_ACTIONS);
        List<ComponentStruct> actions = stateContext.getDynamicActions();

        if (savedActions != null && !savedActions.isEmpty()) {
            for (Object object : savedActions) {
                ComponentStruct action = new ComponentStruct();
                action.restoreState(context, object);
                if (ComponentStruct.ADD.equals(action.action)) {
                    restoreDynamicAdd(context, state, action);
                }
                if (ComponentStruct.REMOVE.equals(action.action)) {
                    restoreDynamicRemove(context, action);
View Full Code Here

         * @param component the UI component to add to the list as a REMOVE.
         */
        private void handleRemove(FacesContext context, UIComponent component) {
            if (component.isInView()) {
                decrementDynamicChildCount(component.getParent());
                ComponentStruct struct = new ComponentStruct();
                struct.action = ComponentStruct.REMOVE;
                struct.clientId = component.getClientId(context);
                struct.id = component.getId();
                handleAddRemoveWithAutoPrune(component, struct);
            }           
View Full Code Here

                        Map.Entry entry = (Map.Entry) entries.next();
                        if (entry.getValue() == component) {
                            incrementDynamicChildCount(component.getParent());
                            component.clearInitialState();
                            component.getAttributes().put(DYNAMIC_COMPONENT, component.getParent().getChildren().indexOf(component));
                            ComponentStruct struct = new ComponentStruct();
                            struct.action = ComponentStruct.ADD;
                            struct.facetName = entry.getKey().toString();
                            struct.parentClientId = component.getParent().getClientId(context);
                            struct.clientId = component.getClientId(context);
                            struct.id = component.getId();
                            handleAddRemoveWithAutoPrune(component, struct);
                        }
                    }
                }
                else {
                    incrementDynamicChildCount(component.getParent());
                    component.clearInitialState();
                    component.getAttributes().put(DYNAMIC_COMPONENT, component.getParent().getChildren().indexOf(component));
                    ComponentStruct struct = new ComponentStruct();
                    struct.action = ComponentStruct.ADD;
                    struct.parentClientId = component.getParent().getClientId(context);
                    struct.clientId = component.getClientId(context);
                    struct.id = component.getId();
                    handleAddRemoveWithAutoPrune(component, struct);
View Full Code Here

                actionList.add(struct);
                componentMap.put(struct.clientId, component);
            } else {
                int lastIndex = actionList.lastIndexOf(struct);
                if (lastIndex == firstIndex) {
                    ComponentStruct previousStruct = actionList.get(firstIndex);
                    if (ComponentStruct.ADD.equals(previousStruct.action)) {
                        if (ComponentStruct.ADD.equals(struct.action)) {
                            throw new FacesException("Cannot add the same component twice: " + struct.clientId);
                        }
                        if (ComponentStruct.REMOVE.equals(struct.action)) {
View Full Code Here

        List<Object> savedActions = (List<Object>) stateMap.get(DYNAMIC_ACTIONS);
        List<ComponentStruct> actions = stateContext.getDynamicActions();

        if (savedActions != null && !savedActions.isEmpty()) {
            for (Object object : savedActions) {
                ComponentStruct action = new ComponentStruct();
                action.restoreState(context, object);
                if (ComponentStruct.ADD.equals(action.action)) {
                    restoreDynamicAdd(context, stateMap, action);
                }
                if (ComponentStruct.REMOVE.equals(action.action)) {
                    restoreDynamicRemove(context, action);
View Full Code Here

TOP

Related Classes of com.sun.faces.util.ComponentStruct

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.