Package javax.faces.component.behavior

Examples of javax.faces.component.behavior.ClientBehaviorHolder


     */
    public static void decodeClientBehaviors(FacesContext facesContext, UIComponent component)
    {
        if (component instanceof ClientBehaviorHolder)
        {
            ClientBehaviorHolder clientBehaviorHolder = (ClientBehaviorHolder) component;
            Map<String, List<ClientBehavior>> clientBehaviors = clientBehaviorHolder
                    .getClientBehaviors();
            if (clientBehaviors != null && !clientBehaviors.isEmpty())
            {
                Map<String, String> paramMap = facesContext
                        .getExternalContext().getRequestParameterMap();
View Full Code Here


          }
                break;
              case BEHAVIOR:
                if (component instanceof ClientBehaviorHolder) {

                  ClientBehaviorHolder clientBehaviorHolder = (ClientBehaviorHolder) component;
                  List<ClientBehavior> behaviors = clientBehaviorHolder.getClientBehaviors().get(attachedEventName);

                  if (behaviors == null || !behaviors.contains(this)) { // Guard against adding ourselves twice
                    clientBehaviorHolder.addClientBehavior(attachedEventName, attachedBehavior);
                  }
                }
                break;
              case AFTER:
          for (UIComponent childComponent : getChildren()) {
View Full Code Here

     * @since 4.0.0
     */
    public static void decodeClientBehaviors(FacesContext facesContext,
                                             UIComponent component) {
        if (component instanceof ClientBehaviorHolder) {
            ClientBehaviorHolder clientBehaviorHolder = (ClientBehaviorHolder) component;

            Map<String, List<ClientBehavior>> clientBehaviors =
                    clientBehaviorHolder.getClientBehaviors();

            if (clientBehaviors != null && !clientBehaviors.isEmpty()) {
                Map<String, String> paramMap = facesContext.getExternalContext().
                        getRequestParameterMap();

View Full Code Here

     * @since 4.0.0
     */
    public static void decodeClientBehaviors(FacesContext facesContext,
                                             UIComponent component) {
        if (component instanceof ClientBehaviorHolder) {
            ClientBehaviorHolder clientBehaviorHolder = (ClientBehaviorHolder) component;

            Map<String, List<ClientBehavior>> clientBehaviors =
                    clientBehaviorHolder.getClientBehaviors();

            if (clientBehaviors != null && !clientBehaviors.isEmpty()) {
                Map<String, String> paramMap = facesContext.getExternalContext().
                        getRequestParameterMap();

View Full Code Here

     * @since 4.0.0
     */
    public static void decodeClientBehaviors(FacesContext facesContext,
                                             UIComponent component) {
        if (component instanceof ClientBehaviorHolder) {
            ClientBehaviorHolder clientBehaviorHolder = (ClientBehaviorHolder) component;

            Map<String, List<ClientBehavior>> clientBehaviors =
                    clientBehaviorHolder.getClientBehaviors();

            if (clientBehaviors != null && !clientBehaviors.isEmpty()) {
                Map<String, String> paramMap = facesContext.getExternalContext().
                        getRequestParameterMap();

View Full Code Here

     */
    public static void decodeClientBehaviors(FacesContext facesContext, UIComponent component)
    {
        if (component instanceof ClientBehaviorHolder)
        {
            ClientBehaviorHolder clientBehaviorHolder = (ClientBehaviorHolder) component;
            Map<String, List<ClientBehavior>> clientBehaviors = clientBehaviorHolder
                    .getClientBehaviors();
            if (clientBehaviors != null && !clientBehaviors.isEmpty())
            {
                Map<String, String> paramMap = facesContext
                        .getExternalContext().getRequestParameterMap();
View Full Code Here

        // Retrieve the current FaceletContext from FacesContext object
        FaceletContext faceletContext = (FaceletContext) context
                .getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);

        // cast to a ClientBehaviorHolder
        ClientBehaviorHolder cvh = (ClientBehaviorHolder) parent;
       
        String eventName = getEventName();
        if (eventName == null)
        {
            eventName = cvh.getDefaultEventName();
            if (eventName == null)
            {
                if (_wrapMode)
                {
                    // No eventName defined, we can't apply this tag to this component, because
                    // there is no event defined to attach it, but since we are in wrap mode
                    // we have here the case that the component could not be the target
                    // for this attached object.
                    return;
                }
                else
                {
                    throw new TagAttributeException(_event,
                            "eventName could not be defined for f:ajax tag with no wrap mode.");
                }
            }
        }
        else if (!cvh.getEventNames().contains(eventName))
        {
            if (_wrapMode)
            {
                // The current component does not implement the event selected,
                // this ajax behavior cannot be applied, but we can't throw any exception
                // since we are in wrap mode and we have here the case that the
                // component could not be the target for this attached object.
                return;
            }
            else
            {
                throw new TagAttributeException(_event,
                        "event it is not a valid eventName defined for this component");
            }
        }
       
        Map<String, List<ClientBehavior>> clientBehaviors = cvh.getClientBehaviors();

        List<ClientBehavior> clientBehaviorList = clientBehaviors.get(eventName);
        if (clientBehaviorList != null && !clientBehaviorList.isEmpty())
        {
            for (ClientBehavior cb : clientBehaviorList)
            {
                if (cb instanceof AjaxBehavior)
                {
                    // The most inner one has been applied, so according to
                    // jsf 2.0 spec section 10.4.1.1 it is not necessary to apply
                    // this one, because the inner one has precendece over
                    // the outer one.
                    return;
                }
            }
        }

        AjaxBehavior ajaxBehavior = createBehavior(context);

        if (_disabled != null)
        {
            if (_disabled.isLiteral())
            {
                ajaxBehavior.setDisabled(_disabled.getBoolean(faceletContext));
            }
            else
            {
                ajaxBehavior.setValueExpression("disabled", _disabled
                        .getValueExpression(faceletContext, Boolean.class));
            }
        }
        if (_execute != null)
        {
            ajaxBehavior.setValueExpression("execute", _execute
                    .getValueExpression(faceletContext, Object.class));
        }
        if (_immediate != null)
        {
            if (_immediate.isLiteral())
            {
                ajaxBehavior
                        .setImmediate(_immediate.getBoolean(faceletContext));
            }
            else
            {
                ajaxBehavior.setValueExpression("immediate", _immediate
                        .getValueExpression(faceletContext, Boolean.class));
            }
        }
        if (_listener != null)
        {
            MethodExpression expr = _listener.getMethodExpression(
                    faceletContext, Void.TYPE, AJAX_BEHAVIOR_LISTENER_SIG);
            AjaxBehaviorListener abl = new AjaxBehaviorListenerImpl(expr);
            ajaxBehavior.addAjaxBehaviorListener(abl);
        }
        if (_onerror != null)
        {
            if (_onerror.isLiteral())
            {
                ajaxBehavior.setOnerror(_onerror.getValue(faceletContext));
            }
            else
            {
                ajaxBehavior.setValueExpression("onerror", _onerror
                        .getValueExpression(faceletContext, String.class));
            }
        }
        if (_onevent != null)
        {
            if (_onevent.isLiteral())
            {
                ajaxBehavior.setOnevent(_onevent.getValue(faceletContext));
            }
            else
            {
                ajaxBehavior.setValueExpression("onevent", _onevent
                        .getValueExpression(faceletContext, String.class));
            }
        }
        if (_render != null)
        {
            ajaxBehavior.setValueExpression("render", _render
                    .getValueExpression(faceletContext, Object.class));
        }
       
        cvh.addClientBehavior(eventName, ajaxBehavior);
    }
View Full Code Here

     */
    public static void decodeClientBehaviors(FacesContext facesContext, UIComponent component)
    {
        if (component instanceof ClientBehaviorHolder)
        {
            ClientBehaviorHolder clientBehaviorHolder = (ClientBehaviorHolder) component;
            Map<String, List<ClientBehavior>> clientBehaviors = clientBehaviorHolder
                    .getClientBehaviors();
            if (clientBehaviors != null && !clientBehaviors.isEmpty())
            {
                Map<String, String> paramMap = facesContext
                        .getExternalContext().getRequestParameterMap();
View Full Code Here

        // no-op
    }

    public void addClientBehavior(String eventName, ClientBehavior behavior) {
        if (parent instanceof ClientBehaviorHolder) {
            ClientBehaviorHolder parentHolder = (ClientBehaviorHolder) parent;
            if (virtualEvent.equals(eventName)) {
                parentHolder.addClientBehavior(event, behavior);
            }
        } else {
            throw new FacesException(
                  "Unable to attach behavior to non-ClientBehaviorHolder parent:"
                  + parent);
View Full Code Here

    }

    public Map<String, List<ClientBehavior>> getClientBehaviors() {
        if (parent instanceof ClientBehaviorHolder) {
            ClientBehaviorHolder parentHolder = (ClientBehaviorHolder) parent;
            Map<String, List<ClientBehavior>> behaviors = new HashMap<String, List<ClientBehavior>>(
                  1);
            behaviors.put(virtualEvent, parentHolder.getClientBehaviors().get(event));
            return Collections.unmodifiableMap(behaviors);
        } else {
            throw new FacesException(
                  "Unable to get behaviors from non-ClientBehaviorHolder parent:"
                  + parent);
View Full Code Here

TOP

Related Classes of javax.faces.component.behavior.ClientBehaviorHolder

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.