Package javax.faces.component

Examples of javax.faces.component.ContextCallback


        facet.setId("_facet");
        child.setId("_child");

        boolean invocationResult;
        final TestCallback callback = new TestCallback();
        invocationResult = mockDataAdaptor.invokeOnComponent(facesContext, "_data", new ContextCallback() {
            public void invokeContextCallback(FacesContext context, UIComponent target) {
                callback.getAndIncrement();
                assertEquals(mockDataAdaptor, target);
                assertEquals("_data", target.getClientId());
            }
        });

        assertTrue(invocationResult);
        assertEquals(1, callback.get());
        callback.reset();

        final char separatorChar = UINamingContainer.getSeparatorChar(facesContext);
        invocationResult = mockDataAdaptor.invokeOnComponent(facesContext, "_data" + separatorChar + "_facet",
            new ContextCallback() {
                public void invokeContextCallback(FacesContext context, UIComponent target) {
                    callback.getAndIncrement();
                    assertEquals(facet, target);
                    assertEquals("_data" + separatorChar + "_facet", target.getClientId());
                }
            });

        assertTrue(invocationResult);
        assertEquals(1, callback.get());
        callback.reset();

        invocationResult = mockDataAdaptor.invokeOnComponent(facesContext, "_data" + separatorChar + "2" + separatorChar
            + "_child", new ContextCallback() {
            public void invokeContextCallback(FacesContext context, UIComponent target) {
                callback.getAndIncrement();
                assertEquals(child, target);
                assertEquals(data.get(2), getVarValue());
                assertEquals("_data" + separatorChar + "2" + separatorChar + "_child", target.getClientId());
            }
        });

        assertTrue(invocationResult);
        assertEquals(1, callback.get());
        callback.reset();

        invocationResult = mockDataAdaptor.invokeOnComponent(facesContext, "_data" + separatorChar + "100" + separatorChar
            + "_child", new ContextCallback() {
            public void invokeContextCallback(FacesContext context, UIComponent target) {
                fail();
            }
        });
        assertFalse(invocationResult);

        invocationResult = mockDataAdaptor.invokeOnComponent(facesContext, "_data" + separatorChar + "nonExistentComponent",
            new ContextCallback() {
                public void invokeContextCallback(FacesContext context, UIComponent target) {
                    fail();
                }
            });
        assertFalse(invocationResult);
View Full Code Here


               
                if (clientIdsRemoved != null)
                {
                    for (String clientId : clientIdsRemoved)
                    {
                        view.invokeOnComponent(context, clientId, new ContextCallback()
                            {
                                public void invokeContextCallback(FacesContext context,
                                        UIComponent target)
                                {
                                    if (target.getParent() != null)
                                    {
                                        target.getParent().getChildren().remove(target);
                                    }
                                }
                            });
                    }
                }
               
                List<String> clientIdsAdded = getClientIdsAdded(view);
                if (clientIdsAdded != null)
                {
                    for (String clientId : clientIdsAdded)
                    {
                        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 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 (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 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

     */
    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

     */
    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

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

        if (DnDValidator.validateAcceptTypes(facesContext,
            draggable, dropzone,
            dragType, acceptedTypes)) {
         
          // Make sure that we will have OnDrag event occur first
          facesContext.getViewRoot().invokeOnComponent(facesContext, isDraggable ? targetId : sourceId, new ContextCallback() {
            public void invokeContextCallback(FacesContext fc,
                      UIComponent targetComponent) {
             
              processEvent(targetComponent, fc, dragEventInfo.dndEvent, dragEventInfo.eventCallback,
                  dropEventInfo.type, dropEventInfo.value);
             
              dropEventInfo.dndEvent.queue();
            }
          });
         
          facesContext.getViewRoot().invokeOnComponent(facesContext, isDraggable ? sourceId : targetId, new ContextCallback() {
            public void invokeContextCallback(FacesContext fc,
                      UIComponent targetComponent) {
             
              processEvent(targetComponent, fc, dropEventInfo.dndEvent, dropEventInfo.eventCallback,
                  dragEventInfo.type, dragEventInfo.value);
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

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.