Examples of VisitCallback


Examples of javax.faces.component.visit.VisitCallback

        VisitContext partialVisitContext = VisitContext.createVisitContext(facesContext, idsToVisit,
            EnumSet.of(VisitHint.SKIP_UNRENDERED));

        final TestCallback callback = new TestCallback();
        mockDataAdaptor.visitTree(fullVisitContext, new VisitCallback() {
            public VisitResult visit(VisitContext context, UIComponent target) {
                callback.getAndIncrement();
                assertNotNull(target);

                return VisitResult.ACCEPT;
            }
        });

        assertEquals(1 /* adaptor itself */+ 1 /* facet */+ data.size(), callback.get());

        callback.reset();

        mockDataAdaptor.visitTree(partialVisitContext, new VisitCallback() {
            public VisitResult visit(VisitContext context, UIComponent target) {
                callback.getAndIncrement();
                assertNotNull(target);
                assertTrue(idsToVisit.contains(target.getClientId()));
                return VisitResult.ACCEPT;
            }
        });

        assertEquals(idsToVisit.size(), callback.get());

        callback.reset();

        mockDataAdaptor.visitTree(fullVisitContext, new VisitCallback() {
            public VisitResult visit(VisitContext context, UIComponent target) {
                callback.getAndIncrement();

                if (child.equals(target)
                    && child.getClientId().equals("_data" + separatorChar + "1" + separatorChar + "_child")) {
View Full Code Here

Examples of javax.faces.component.visit.VisitCallback

    {
        facesContext.getAttributes().put(SKIP_ITERATION_HINT, Boolean.TRUE);
        try
        {
            EnumSet<VisitHint> visitHints = EnumSet.of(VisitHint.SKIP_ITERATION);
            uiViewRoot.visitTree( VisitContext.createVisitContext (facesContext, null, visitHints), new VisitCallback()
            {
                public VisitResult visit(VisitContext context, UIComponent target)
                {
                    FacesContext facesContext = context.getFacesContext();
                    Object state;
View Full Code Here

Examples of javax.faces.component.visit.VisitCallback

         * UINamingContainer that does not prepend its ID. So we are going to
         * walk the tree to find it.
         */
        if (found.isEmpty()) {
            VisitContext visitContext = VisitContext.createVisitContext(context);
            context.getViewRoot().visitTree(visitContext, new VisitCallback() {

                public VisitResult visit(VisitContext visitContext, UIComponent component) {
                    VisitResult result = VisitResult.ACCEPT;
                    if (component.getClientId(visitContext.getFacesContext()).equals(clientId)) {
                        found.add(component);
View Full Code Here

Examples of javax.faces.component.visit.VisitCallback

            // during state saving.  It should be removed at some point.
            facesContext.getAttributes().put(SKIP_ITERATION_HINT, true);

            Set<VisitHint> hints = EnumSet.of(VisitHint.SKIP_ITERATION);
            VisitContext visitContext = VisitContext.createVisitContext(facesContext, null, hints);
            root.visitTree(visitContext, new VisitCallback() {

                        public VisitResult visit(VisitContext context, UIComponent target) {
                            postRestoreStateEvent.setComponent(target);
                            target.processEvent(postRestoreStateEvent);
                            //noinspection ReturnInsideFinallyBlock
View Full Code Here

Examples of javax.faces.component.visit.VisitCallback

         * UINamingContainer that does not prepend its ID. So we are going to
         * walk the tree to find it.
         */
        if (found.isEmpty()) {
            VisitContext visitContext = VisitContext.createVisitContext(context);
            context.getViewRoot().visitTree(visitContext, new VisitCallback() {

                public VisitResult visit(VisitContext visitContext, UIComponent component) {
                    VisitResult result = VisitResult.ACCEPT;
                    if (component.getClientId(visitContext.getFacesContext()).equals(clientId)) {
                        found.add(component);
View Full Code Here

Examples of javax.faces.component.visit.VisitCallback

         * UINamingContainer that does not prepend its ID. So we are going to
         * walk the tree to find it.
         */
        if (found.isEmpty()) {
            VisitContext visitContext = VisitContext.createVisitContext(context);
            context.getViewRoot().visitTree(visitContext, new VisitCallback() {

                public VisitResult visit(VisitContext visitContext, UIComponent component) {
                    VisitResult result = VisitResult.ACCEPT;
                    if (component.getClientId(visitContext.getFacesContext()).equals(clientId)) {
                        found.add(component);
View Full Code Here

Examples of javax.faces.component.visit.VisitCallback

    {
        facesContext.getAttributes().put(SKIP_ITERATION_HINT, Boolean.TRUE);
        try
        {
            uiViewRoot.visitTree( getVisitContextFactory().getVisitContext(
                    facesContext, null, null), new VisitCallback()
            {
                public VisitResult visit(VisitContext context, UIComponent target)
                {
                    FacesContext facesContext = context.getFacesContext();
                    Object state;
View Full Code Here

Examples of javax.faces.component.visit.VisitCallback

        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)) {
View Full Code Here

Examples of javax.faces.component.visit.VisitCallback

                // during state saving.  It should be removed at some point.
                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;
                    }

                });



                // Handle dynamic add/removes
                //noinspection unchecked
                List<String> removeList = (List<String>) state.get(CLIENTIDS_TO_REMOVE_NAME);
                if (null != removeList && !removeList.isEmpty()) {
                    for (String cur : removeList) {
                        boolean trackMods = stateContext.trackViewModifications();
                        if (trackMods) {
                            stateContext.setTrackViewModifications(false);
                        }
                        viewRoot.invokeOnComponent(context, cur, new ContextCallback() {

                            public void invokeContextCallback(FacesContext context, UIComponent target) {
                                UIComponent parent = target.getParent();
                                if (null != parent) {
                                    parent.getChildren().remove(target);
                                }
                            }

                        });
                        if (trackMods) {
                            stateContext.setTrackViewModifications(true);
                        }
                    }
                }

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

Examples of javax.faces.component.visit.VisitCallback

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

                VisitContext visitContext = VisitContext.createVisitContext(context, null, hints);
                child.visitTree(visitContext, new VisitCallback() {

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

                        if (isForm(component)) {
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.