Package javax.faces.component

Examples of javax.faces.component.ContextCallback


                    {
                        for (String clientId : clientIdsRemoved)
                        {
                            if (!idsRemovedSet.contains(clientId))
                            {
                                view.invokeOnComponent(context, clientId, new ContextCallback()
                                    {
                                        public void invokeContextCallback(FacesContext context,
                                                UIComponent target)
                                        {
                                            if (target.getParent() != null)
                                            {
                                                if (!target.getParent().getChildren().remove(target))
                                                {
                                                    String key = null;
                                                    if (target.getParent().getFacetCount() > 0)
                                                    {
                                                        for (Map.Entry<String, UIComponent> entry : target.getParent().getFacets().entrySet())
                                                        {
                                                            if (entry.getValue()==target)
                                                            {
                                                                key = entry.getKey();
                                                                break;
                                                            }
                                                        }
                                                    }
                                                    if (key != null)
                                                    {
                                                        target.getParent().getFacets().remove(key);
                                                    }
                                                }
                                            }
                                        }
                                    });
                                idsRemovedSet.add(clientId);
                            }
                        }
                        clientIdsRemoved.clear();
                        clientIdsRemoved.addAll(idsRemovedSet);
                    }
                    finally
                    {
                        context.getAttributes().remove(FaceletViewDeclarationLanguage.REMOVING_COMPONENTS_BUILD);
                    }
                }
               
                List<String> clientIdsAdded = getClientIdsAdded(view);
                if (clientIdsAdded != null)
                {
                    Set<String> idsAddedSet = new HashSet<String>(HashMapUtils.calcCapacity(clientIdsAdded.size()));
                    for (String clientId : clientIdsAdded)
                    {
                        if (!idsAddedSet.contains(clientId))
                        {
                            final AttachedFullStateWrapper wrapper = (AttachedFullStateWrapper) states.get(clientId);
                            if (wrapper != null)
                            {
                                final Object[] addedState = (Object[]) wrapper.getWrappedStateObject();
                                if (addedState != null)
                                {
                                    if (addedState.length == 2)
                                    {
                                        view = (UIViewRoot) internalRestoreTreeStructure((TreeStructComponent) addedState[0]);
                                        view.processRestoreState(context, addedState[1]);
                                        break;
                                    }
                                    else
                                    {
                                        final String parentClientId = (String) addedState[0];
                                        view.invokeOnComponent(context, parentClientId, new ContextCallback()
                                        {
                                            public void invokeContextCallback(FacesContext context,
                                                    UIComponent target)
                                            {
                                                if (addedState[1] != null)
View Full Code Here


                        for (int i = 0, size = clientIdsRemoved.size(); i < size; i++)
                        {
                            String clientId = clientIdsRemoved.get(i);
                            if (!idsRemovedSet.contains(clientId))
                            {
                                view.invokeOnComponent(context, clientId, new ContextCallback()
                                    {
                                        public void invokeContextCallback(FacesContext context,
                                                UIComponent target)
                                        {
                                            if (target.getParent() != null)
                                            {
                                                if (!target.getParent().getChildren().remove(target))
                                                {
                                                    String key = null;
                                                    if (target.getParent().getFacetCount() > 0)
                                                    {
                                                        for (Map.Entry<String, UIComponent> entry :
                                                                target.getParent().getFacets().entrySet())
                                                        {
                                                            if (entry.getValue()==target)
                                                            {
                                                                key = entry.getKey();
                                                                break;
                                                            }
                                                        }
                                                    }
                                                    if (key != null)
                                                    {
                                                        target.getParent().getFacets().remove(key);
                                                    }
                                                }
                                            }
                                        }
                                    });
                                idsRemovedSet.add(clientId);
                            }
                        }
                        clientIdsRemoved.clear();
                        clientIdsRemoved.addAll(idsRemovedSet);
                    }
                    finally
                    {
                        context.getAttributes().remove(FaceletViewDeclarationLanguage.REMOVING_COMPONENTS_BUILD);
                    }
                }
               
                List<String> clientIdsAdded = getClientIdsAdded(view);
                if (clientIdsAdded != null)
                {
                    Set<String> idsAddedSet = new HashSet<String>(HashMapUtils.calcCapacity(clientIdsAdded.size()));
                    // perf: clientIds are ArrayList: see method setClientsIdsAdded(String)
                    for (int i = 0, size = clientIdsAdded.size(); i < size; i++)
                    {
                        String clientId = clientIdsAdded.get(i);
                        if (!idsAddedSet.contains(clientId))
                        {
                            final AttachedFullStateWrapper wrapper = (AttachedFullStateWrapper) states.get(clientId);
                            if (wrapper != null)
                            {
                                final Object[] addedState = (Object[]) wrapper.getWrappedStateObject();
                                if (addedState != null)
                                {
                                    if (addedState.length == 2)
                                    {
                                        view = (UIViewRoot)
                                                internalRestoreTreeStructure((TreeStructComponent) addedState[0]);
                                        view.processRestoreState(context, addedState[1]);
                                        break;
                                    }
                                    else
                                    {
                                        final String parentClientId = (String) addedState[0];
                                        view.invokeOnComponent(context, parentClientId, new ContextCallback()
                                        {
                                            public void invokeContextCallback(FacesContext context,
                                                    UIComponent target)
                                            {
                                                if (addedState[1] != null)
View Full Code Here

                        for (int i = 0, size = clientIdsRemoved.size(); i < size; i++)
                        {
                            String clientId = clientIdsRemoved.get(i);
                            if (!idsRemovedSet.contains(clientId))
                            {
                                view.invokeOnComponent(context, clientId, new ContextCallback()
                                    {
                                        public void invokeContextCallback(FacesContext context,
                                                UIComponent target)
                                        {
                                            if (target.getParent() != null)
                                            {
                                                if (!target.getParent().getChildren().remove(target))
                                                {
                                                    String key = null;
                                                    if (target.getParent().getFacetCount() > 0)
                                                    {
                                                        for (Map.Entry<String, UIComponent> entry :
                                                                target.getParent().getFacets().entrySet())
                                                        {
                                                            if (entry.getValue()==target)
                                                            {
                                                                key = entry.getKey();
                                                                break;
                                                            }
                                                        }
                                                    }
                                                    if (key != null)
                                                    {
                                                        target.getParent().getFacets().remove(key);
                                                    }
                                                }
                                            }
                                        }
                                    });
                                idsRemovedSet.add(clientId);
                            }
                        }
                        clientIdsRemoved.clear();
                        clientIdsRemoved.addAll(idsRemovedSet);
                    }
                    finally
                    {
                        context.getAttributes().remove(FaceletViewDeclarationLanguage.REMOVING_COMPONENTS_BUILD);
                    }
                }
               
                List<String> clientIdsAdded = getClientIdsAdded(view);
                if (clientIdsAdded != null)
                {
                    Set<String> idsAddedSet = new HashSet<String>(HashMapUtils.calcCapacity(clientIdsAdded.size()));
                    // perf: clientIds are ArrayList: see method setClientsIdsAdded(String)
                    for (int i = 0, size = clientIdsAdded.size(); i < size; i++)
                    {
                        String clientId = clientIdsAdded.get(i);
                        if (!idsAddedSet.contains(clientId))
                        {
                            final AttachedFullStateWrapper wrapper = (AttachedFullStateWrapper) states.get(clientId);
                            if (wrapper != null)
                            {
                                final Object[] addedState = (Object[]) wrapper.getWrappedStateObject();
                                if (addedState != null)
                                {
                                    if (addedState.length == 2)
                                    {
                                        view = (UIViewRoot)
                                                internalRestoreTreeStructure((TreeStructComponent) addedState[0]);
                                        view.processRestoreState(context, addedState[1]);
                                        break;
                                    }
                                    else
                                    {
                                        final String parentClientId = (String) addedState[0];
                                        view.invokeOnComponent(context, parentClientId, new ContextCallback()
                                        {
                                            public void invokeContextCallback(FacesContext context,
                                                    UIComponent target)
                                            {
                                                if (addedState[1] != null)
View Full Code Here

            //noinspection unchecked
            List<String> removeList = (List<String>) state.get(CLIENTIDS_TO_REMOVE_NAME);
            if (null != removeList && !removeList.isEmpty()) {
                for (String cur : removeList) {
                    setIgnoreRemoveEvent(context, true);
                    viewRoot.invokeOnComponent(context, cur, new ContextCallback() {

                        public void invokeContextCallback(FacesContext context, UIComponent target) {
                            UIComponent parent = target.getParent();
                            if (null != parent) {
                                parent.getChildren().remove(target);
                            }
                        }
                       
                    });
                    setIgnoreRemoveEvent(context, false);
                }
            }
            Object restoredAddList[] = (Object []) state.get(CLIENTIDS_TO_ADD_NAME);
            if (null != restoredAddList && 0 < restoredAddList.length) { 
                // 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.invokeOnComponent(context, finalCur.parentClientId,
                            new ContextCallback() {
                        public void invokeContextCallback(FacesContext context, UIComponent parent) {
                            // Create the child
                            StateHolderSaver saver = (StateHolderSaver) state.get(finalCur.clientId);
                            UIComponent toAdd = (UIComponent) saver.restore(context);
                            int idx = finalCur.indexOfChildInParent;
View Full Code Here

                    {
                        for (String clientId : clientIdsRemoved)
                        {
                            if (!idsRemovedSet.contains(clientId))
                            {
                                view.invokeOnComponent(context, clientId, new ContextCallback()
                                    {
                                        public void invokeContextCallback(FacesContext context,
                                                UIComponent target)
                                        {
                                            if (target.getParent() != null)
                                            {
                                                if (!target.getParent().getChildren().remove(target))
                                                {
                                                    String key = null;
                                                    if (target.getParent().getFacetCount() > 0)
                                                    {
                                                        for (Map.Entry<String, UIComponent> entry : target.getParent().getFacets().entrySet())
                                                        {
                                                            if (entry.getValue()==target)
                                                            {
                                                                key = entry.getKey();
                                                                break;
                                                            }
                                                        }
                                                    }
                                                    if (key != null)
                                                    {
                                                        target.getParent().getFacets().remove(key);
                                                    }
                                                }
                                            }
                                        }
                                    });
                                idsRemovedSet.add(clientId);
                            }
                        }
                        clientIdsRemoved.clear();
                        clientIdsRemoved.addAll(idsRemovedSet);
                    }
                    finally
                    {
                        context.getAttributes().remove(FaceletViewDeclarationLanguage.REMOVING_COMPONENTS_BUILD);
                    }
                }
               
                List<String> clientIdsAdded = getClientIdsAdded(view);
                if (clientIdsAdded != null)
                {
                    Set<String> idsAddedSet = new HashSet<String>(HashMapUtils.calcCapacity(clientIdsAdded.size()));
                    for (String clientId : clientIdsAdded)
                    {
                        if (!idsAddedSet.contains(clientId))
                        {
                            final AttachedFullStateWrapper wrapper = (AttachedFullStateWrapper) states.get(clientId);
                            if (wrapper != null)
                            {
                                final Object[] addedState = (Object[]) wrapper.getWrappedStateObject();
                                if (addedState != null)
                                {
                                    if (addedState.length == 2)
                                    {
                                        view = (UIViewRoot) internalRestoreTreeStructure((TreeStructComponent) addedState[0]);
                                        view.processRestoreState(context, addedState[1]);
                                        break;
                                    }
                                    else
                                    {
                                        final String parentClientId = (String) addedState[0];
                                        view.invokeOnComponent(context, parentClientId, new ContextCallback()
                                        {
                                            public void invokeContextCallback(FacesContext context,
                                                    UIComponent target)
                                            {
                                                if (addedState[1] != null)
View Full Code Here

     */
    private UIComponent locateComponentByClientId(final FacesContext context, final UIComponent parent, final String clientId) {
        final List<UIComponent> found = new ArrayList<UIComponent>();
        UIComponent result = null;

        parent.invokeOnComponent(context, clientId, new ContextCallback() {

            public void invokeContextCallback(FacesContext context, UIComponent target) {
                found.add(target);
            }
        });
View Full Code Here

                        for (int i = 0, size = clientIdsRemoved.size(); i < size; i++)
                        {
                            String clientId = clientIdsRemoved.get(i);
                            if (!idsRemovedSet.contains(clientId))
                            {
                                view.invokeOnComponent(context, clientId, new ContextCallback()
                                    {
                                        public void invokeContextCallback(FacesContext context,
                                                UIComponent target)
                                        {
                                            if (target.getParent() != null)
                                            {
                                                if (!target.getParent().getChildren().remove(target))
                                                {
                                                    String key = null;
                                                    if (target.getParent().getFacetCount() > 0)
                                                    {
                                                        for (Map.Entry<String, UIComponent> entry :
                                                                target.getParent().getFacets().entrySet())
                                                        {
                                                            if (entry.getValue()==target)
                                                            {
                                                                key = entry.getKey();
                                                                break;
                                                            }
                                                        }
                                                    }
                                                    if (key != null)
                                                    {
                                                        target.getParent().getFacets().remove(key);
                                                    }
                                                }
                                            }
                                        }
                                    });
                                idsRemovedSet.add(clientId);
                            }
                        }
                        clientIdsRemoved.clear();
                        clientIdsRemoved.addAll(idsRemovedSet);
                    }
                    finally
                    {
                        context.getAttributes().remove(FaceletViewDeclarationLanguage.REMOVING_COMPONENTS_BUILD);
                    }
                }
               
                List<String> clientIdsAdded = getClientIdsAdded(view);
                if (clientIdsAdded != null)
                {
                    Set<String> idsAddedSet = new HashSet<String>(HashMapUtils.calcCapacity(clientIdsAdded.size()));
                    // perf: clientIds are ArrayList: see method setClientsIdsAdded(String)
                    for (int i = 0, size = clientIdsAdded.size(); i < size; i++)
                    {
                        String clientId = clientIdsAdded.get(i);
                        if (!idsAddedSet.contains(clientId))
                        {
                            final AttachedFullStateWrapper wrapper = (AttachedFullStateWrapper) states.get(clientId);
                            if (wrapper != null)
                            {
                                final Object[] addedState = (Object[]) wrapper.getWrappedStateObject();
                                if (addedState != null)
                                {
                                    if (addedState.length == 2)
                                    {
                                        view = (UIViewRoot)
                                                internalRestoreTreeStructure((TreeStructComponent) addedState[0]);
                                        view.processRestoreState(context, addedState[1]);
                                        break;
                                    }
                                    else
                                    {
                                        final String parentClientId = (String) addedState[0];
                                        view.invokeOnComponent(context, parentClientId, new ContextCallback()
                                        {
                                            public void invokeContextCallback(FacesContext context,
                                                    UIComponent target)
                                            {
                                                if (addedState[1] != null)
View Full Code Here

                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.invokeOnComponent(context, finalCur.parentClientId,
                                new ContextCallback() {
                                    public void invokeContextCallback(FacesContext context, UIComponent parent) {
                                        // Create the child
                                        StateHolderSaver saver = (StateHolderSaver) state.get(finalCur.clientId);
                                        UIComponent toAdd = (UIComponent) saver.restore(context);
                                        int idx = finalCur.indexOfChildInParent;
View Full Code Here

     */
    private UIComponent locateComponentByClientId(final FacesContext context, final String clientId) {
        final List<UIComponent> found = new ArrayList<UIComponent>();
        UIComponent result = null;

        context.getViewRoot().invokeOnComponent(context, clientId, new ContextCallback() {

            public void invokeContextCallback(FacesContext context, UIComponent target) {
                found.add(target);
            }
        });
View Full Code Here

                return;
            }

            String behaviorSourceId = RenderKitUtils.getBehaviorSourceId(context);

            ((UIDataAdaptor) component).invokeOnRow(context, behaviorSourceId, new ContextCallback() {
                public void invokeContextCallback(FacesContext context, UIComponent target) {
                    if (target.equals(component)) {
                        List<ClientBehavior> behaviorsForEvent = behaviors.get(behaviorEvent);
                        if (behaviorsForEvent != null && !behaviorsForEvent.isEmpty()) {
                            for (ClientBehavior behavior : behaviorsForEvent) {
View Full Code Here

TOP

Related Classes of javax.faces.component.ContextCallback

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.