Package org.apache.myfaces.view.facelets.el

Examples of org.apache.myfaces.view.facelets.el.ValueExpressionMethodExpression


                // component #{cc}, the MethodExpression has to be invoked indirectly (via
                // a ValueExpression that points to the real MethodExpression). This happens
                // when other composite components are nested in composite components' implementations.
                if (CompositeComponentELUtils.isCompositeComponentExpression(attributeExpressionString))
                {
                    methodExpression = new ValueExpressionMethodExpression(attributeNameValueExpression);
                }
               
                if (isKnownMethod)
                {
                    for (String target : targetsArray)
View Full Code Here


            {
                // The MethodExpression is on parent composite component attribute map.
                // create a pointer that are referred to the real one that is created in other side
                // (see VDL.retargetMethodExpressions for details)
                ValueExpression valueExpr = this.getValueExpression(ctx, MethodExpression.class);
                methodExpression = new ValueExpressionMethodExpression(valueExpr);
            }
            else
            {
                ExpressionFactory f = ctx.getExpressionFactory();
                methodExpression = f.createMethodExpression(ctx, this.value, type, paramTypes);
View Full Code Here

        // If it is a redirection, a wrapper is used to
        // locate the right instance and call it properly.
        if (ccAttrMeRedirection)
        {
            ((ActionSource2) innerComponent).setActionExpression(
                    new ValueExpressionMethodExpression(attributeNameValueExpression));
        }
        else
        {
            ((ActionSource2) innerComponent).setActionExpression(methodExpression);
        }
View Full Code Here

                if (ccAttrMeRedirection)
                {
                    // Since we require here a method expression, it is necessary to wrap
                    // the ValueExpression into a MethodExpression that handles redirection.
                    innerComponent.getAttributes().put(targetAttributeName,
                            new ValueExpressionMethodExpression(attributeNameValueExpression));
                }
                else
                {
                    innerComponent.getAttributes().put(targetAttributeName, methodExpression);
                }
View Full Code Here

                    throw new ELException("Cannot add parameters to a MethodExpression "
                            + "pointing to cc.attrs");
                }
               
                ValueExpression valueExpr = this.getValueExpression(ctx, Object.class);
                methodExpression = new ValueExpressionMethodExpression(valueExpr);
            }
            else
            {
                ExpressionFactory f = ctx.getExpressionFactory();
                methodExpression = f.createMethodExpression(ctx, this.value, type, paramTypes);
View Full Code Here

                                                    attributeExpressionString, null, EMPTY_CLASS_ARRAY), attributeNameValueExpression);

                                    // If it is a redirection, a wrapper is used to locate the right instance and call it properly.
                                    if (ccAttrMeRedirection)
                                    {
                                        ((ActionSource2)innerComponent).setActionExpression(new ValueExpressionMethodExpression(attributeNameValueExpression));
                                    }
                                    else
                                    {
                                        ((ActionSource2)innerComponent).setActionExpression(methodExpression);
                                    }
                                    if (mctx.isUsingPSSOnThisView() && mctx.isMarkInitialState())
                                    {
                                        innerComponent.markInitialState();
                                    }
                                }
                                else if ("actionListener".equals(attributeName))
                                {
                                    //First try to remove any prevous target if any
                                    ActionListener o = (ActionListener) mctx.removeMethodExpressionTargeted(innerComponent, attributeName);
                                    if (o != null)
                                    {
                                        ((ActionSource2) innerComponent).removeActionListener(o);
                                    }

                                    // target is ActionSource2
                                    ActionListener actionListener = null;
                                    // If it is a redirection, a wrapper is used to locate the right instance and call it properly.
                                    if (ccAttrMeRedirection)
                                    {
                                        actionListener = new RedirectMethodExpressionValueExpressionActionListener(attributeNameValueExpression);
                                    }
                                    else
                                    {
                                        methodExpression = reWrapMethodExpression(context.getApplication().getExpressionFactory().
                                                createMethodExpression(elContext,
                                                        attributeExpressionString, Void.TYPE, ACTION_LISTENER_SIGNATURE), attributeNameValueExpression);

                                        methodExpression2 = reWrapMethodExpression(context.getApplication().getExpressionFactory().
                                                createMethodExpression(elContext,
                                                        attributeExpressionString, Void.TYPE, EMPTY_CLASS_ARRAY), attributeNameValueExpression);

                                        if (mctx.isUsingPSSOnThisView())
                                        {
                                            actionListener = new PartialMethodExpressionActionListener(methodExpression, methodExpression2);
                                        }
                                        else
                                        {
                                            actionListener = new MethodExpressionActionListener(methodExpression, methodExpression2);
                                        }
                                    }
                                    ((ActionSource2) innerComponent).addActionListener(actionListener);
                                    mctx.addMethodExpressionTargeted(innerComponent, attributeName, actionListener);
                                    if (mctx.isUsingPSSOnThisView() && mctx.isMarkInitialState())
                                    {
                                        innerComponent.markInitialState();
                                    }
                                }
                                else if ("validator".equals(attributeName))
                                {
                                    //First try to remove any prevous target if any
                                    Validator o = (Validator) mctx.removeMethodExpressionTargeted(innerComponent, attributeName);
                                    if (o != null)
                                    {
                                        ((EditableValueHolder) innerComponent).removeValidator(o);
                                    }

                                    // target is EditableValueHolder
                                    Validator validator = null;
                                    // If it is a redirection, a wrapper is used to locate the right instance and call it properly.
                                    if (ccAttrMeRedirection)
                                    {
                                        validator = new RedirectMethodExpressionValueExpressionValidator(attributeNameValueExpression);
                                    }
                                    else
                                    {
                                        methodExpression = reWrapMethodExpression(context.getApplication().getExpressionFactory().
                                                createMethodExpression(elContext,
                                                        attributeExpressionString, Void.TYPE,
                                                        VALIDATOR_SIGNATURE), attributeNameValueExpression);
                                        if (mctx.isUsingPSSOnThisView())
                                        {
                                            validator = new PartialMethodExpressionValidator(methodExpression);
                                        }
                                        else
                                        {
                                            validator = new MethodExpressionValidator(methodExpression);
                                        }
                                    }
                                    ((EditableValueHolder) innerComponent).addValidator(validator);
                                    mctx.addMethodExpressionTargeted(innerComponent, attributeName, validator);
                                    if (mctx.isUsingPSSOnThisView() && mctx.isMarkInitialState())
                                    {
                                        innerComponent.markInitialState();
                                    }
                                }
                                else if ("valueChangeListener".equals(attributeName))
                                {
                                    ValueChangeListener o = (ValueChangeListener) mctx.removeMethodExpressionTargeted(innerComponent, attributeName);
                                    if (o != null)
                                    {
                                        ((EditableValueHolder)innerComponent).removeValueChangeListener(o);
                                    }

                                    // target is EditableValueHolder
                                    ValueChangeListener valueChangeListener = null;
                                    // If it is a redirection, a wrapper is used to locate the right instance and call it properly.
                                    if (ccAttrMeRedirection)
                                    {
                                        valueChangeListener = new RedirectMethodExpressionValueExpressionValueChangeListener(attributeNameValueExpression);
                                    }
                                    else
                                    {
                                        methodExpression = reWrapMethodExpression(context.getApplication().getExpressionFactory().
                                                createMethodExpression(elContext,
                                                        attributeExpressionString, Void.TYPE,
                                                        VALUE_CHANGE_LISTENER_SIGNATURE), attributeNameValueExpression);

                                        methodExpression2 = reWrapMethodExpression(context.getApplication().getExpressionFactory().
                                                createMethodExpression(elContext,
                                                        attributeExpressionString, Void.TYPE,
                                                        EMPTY_CLASS_ARRAY), attributeNameValueExpression);

                                        if (mctx.isUsingPSSOnThisView())
                                        {
                                            valueChangeListener = new PartialMethodExpressionValueChangeListener(methodExpression, methodExpression2);
                                        }
                                        else
                                        {
                                            valueChangeListener = new MethodExpressionValueChangeListener(methodExpression, methodExpression2);
                                        }
                                    }
                                    ((EditableValueHolder) innerComponent).addValueChangeListener(valueChangeListener);
                                    mctx.addMethodExpressionTargeted(innerComponent, attributeName, valueChangeListener);
                                    if (mctx.isUsingPSSOnThisView() && mctx.isMarkInitialState())
                                    {
                                        innerComponent.markInitialState();
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        // composite:attribute targets property only has sense for action, actionListener,
                        // validator or valueChangeListener. This means we have to retarget the method expression
                        // to the topLevelComponent.

                        // Since a MethodExpression has no state, we can use it multiple times without problem, so
                        // first create it here.
                        methodSignature = methodSignature.trim();
                        methodExpression = context.getApplication().getExpressionFactory().
                                createMethodExpression(elContext,
                                        attributeExpressionString, _getReturnType(methodSignature),
                                        _getParameters(methodSignature));

                        methodExpression = reWrapMethodExpression(methodExpression, attributeNameValueExpression);

                        UIComponent topLevelComponentBase = topLevelComponent.getFacet(UIComponent.COMPOSITE_FACET_NAME);

                        for (String target : targetsArray)
                        {
                            UIComponent innerComponent = ComponentSupport.findComponentChildOrFacetFrom(context, topLevelComponentBase, target);

                            if (innerComponent == null)
                            {
                                continue;
                            }

                            // If a component is found, that means the expression should be retarget to the
                            // components related
                            if (isCompositeComponentRetarget(context, innerComponent, attributeName))
                            {
                                innerComponent.getAttributes().put(attributeName, attributeNameValueExpression);

                                mctx.clearMethodExpressionAttribute(innerComponent, attributeName);

                                retargetMethodExpressions(context, innerComponent);
                                if (mctx.isUsingPSSOnThisView() && mctx.isMarkInitialState())
                                {
                                    innerComponent.markInitialState();
                                }
                            }
                            else
                            {
                                //Put the retarget
                                if (ccAttrMeRedirection)
                                {
                                    // Since we require here a method expression, it is necessary to wrap the ValueExpression
                                    // into a MethodExpression that handles redirection.
                                    innerComponent.getAttributes().put(attributeName, new ValueExpressionMethodExpression(attributeNameValueExpression));
                                }
                                else
                                {
                                    innerComponent.getAttributes().put(attributeName, methodExpression);
                                }
View Full Code Here

                                                    attributeExpressionString, null, EMPTY_CLASS_ARRAY), attributeNameValueExpression);

                                    // If it is a redirection, a wrapper is used to locate the right instance and call it properly.
                                    if (ccAttrMeRedirection)
                                    {
                                        ((ActionSource2)innerComponent).setActionExpression(new ValueExpressionMethodExpression(attributeNameValueExpression));
                                    }
                                    else
                                    {
                                        ((ActionSource2)innerComponent).setActionExpression(methodExpression);
                                    }
                                    if (mctx.isUsingPSSOnThisView() && mctx.isMarkInitialState())
                                    {
                                        innerComponent.markInitialState();
                                    }
                                }
                                else if ("actionListener".equals(attributeName))
                                {
                                    //First try to remove any prevous target if any
                                    ActionListener o = (ActionListener) mctx.removeMethodExpressionTargeted(innerComponent, attributeName);
                                    if (o != null)
                                    {
                                        ((ActionSource2) innerComponent).removeActionListener(o);
                                    }

                                    // target is ActionSource2
                                    ActionListener actionListener = null;
                                    // If it is a redirection, a wrapper is used to locate the right instance and call it properly.
                                    if (ccAttrMeRedirection)
                                    {
                                        actionListener = new RedirectMethodExpressionValueExpressionActionListener(attributeNameValueExpression);
                                    }
                                    else
                                    {
                                        methodExpression = reWrapMethodExpression(context.getApplication().getExpressionFactory().
                                                createMethodExpression(elContext,
                                                        attributeExpressionString, Void.TYPE, ACTION_LISTENER_SIGNATURE), attributeNameValueExpression);

                                        methodExpression2 = reWrapMethodExpression(context.getApplication().getExpressionFactory().
                                                createMethodExpression(elContext,
                                                        attributeExpressionString, Void.TYPE, EMPTY_CLASS_ARRAY), attributeNameValueExpression);

                                        if (mctx.isUsingPSSOnThisView())
                                        {
                                            actionListener = new PartialMethodExpressionActionListener(methodExpression, methodExpression2);
                                        }
                                        else
                                        {
                                            actionListener = new MethodExpressionActionListener(methodExpression, methodExpression2);
                                        }
                                    }
                                    ((ActionSource2) innerComponent).addActionListener(actionListener);
                                    mctx.addMethodExpressionTargeted(innerComponent, attributeName, actionListener);
                                    if (mctx.isUsingPSSOnThisView() && mctx.isMarkInitialState())
                                    {
                                        innerComponent.markInitialState();
                                    }
                                }
                                else if ("validator".equals(attributeName))
                                {
                                    //First try to remove any prevous target if any
                                    Validator o = (Validator) mctx.removeMethodExpressionTargeted(innerComponent, attributeName);
                                    if (o != null)
                                    {
                                        ((EditableValueHolder) innerComponent).removeValidator(o);
                                    }

                                    // target is EditableValueHolder
                                    Validator validator = null;
                                    // If it is a redirection, a wrapper is used to locate the right instance and call it properly.
                                    if (ccAttrMeRedirection)
                                    {
                                        validator = new RedirectMethodExpressionValueExpressionValidator(attributeNameValueExpression);
                                    }
                                    else
                                    {
                                        methodExpression = reWrapMethodExpression(context.getApplication().getExpressionFactory().
                                                createMethodExpression(elContext,
                                                        attributeExpressionString, Void.TYPE,
                                                        VALIDATOR_SIGNATURE), attributeNameValueExpression);
                                        if (mctx.isUsingPSSOnThisView())
                                        {
                                            validator = new PartialMethodExpressionValidator(methodExpression);
                                        }
                                        else
                                        {
                                            validator = new MethodExpressionValidator(methodExpression);
                                        }
                                    }
                                    ((EditableValueHolder) innerComponent).addValidator(validator);
                                    mctx.addMethodExpressionTargeted(innerComponent, attributeName, validator);
                                    if (mctx.isUsingPSSOnThisView() && mctx.isMarkInitialState())
                                    {
                                        innerComponent.markInitialState();
                                    }
                                }
                                else if ("valueChangeListener".equals(attributeName))
                                {
                                    ValueChangeListener o = (ValueChangeListener) mctx.removeMethodExpressionTargeted(innerComponent, attributeName);
                                    if (o != null)
                                    {
                                        ((EditableValueHolder)innerComponent).removeValueChangeListener(o);
                                    }

                                    // target is EditableValueHolder
                                    ValueChangeListener valueChangeListener = null;
                                    // If it is a redirection, a wrapper is used to locate the right instance and call it properly.
                                    if (ccAttrMeRedirection)
                                    {
                                        valueChangeListener = new RedirectMethodExpressionValueExpressionValueChangeListener(attributeNameValueExpression);
                                    }
                                    else
                                    {
                                        methodExpression = reWrapMethodExpression(context.getApplication().getExpressionFactory().
                                                createMethodExpression(elContext,
                                                        attributeExpressionString, Void.TYPE,
                                                        VALUE_CHANGE_LISTENER_SIGNATURE), attributeNameValueExpression);

                                        methodExpression2 = reWrapMethodExpression(context.getApplication().getExpressionFactory().
                                                createMethodExpression(elContext,
                                                        attributeExpressionString, Void.TYPE,
                                                        EMPTY_CLASS_ARRAY), attributeNameValueExpression);

                                        if (mctx.isUsingPSSOnThisView())
                                        {
                                            valueChangeListener = new PartialMethodExpressionValueChangeListener(methodExpression, methodExpression2);
                                        }
                                        else
                                        {
                                            valueChangeListener = new MethodExpressionValueChangeListener(methodExpression, methodExpression2);
                                        }
                                    }
                                    ((EditableValueHolder) innerComponent).addValueChangeListener(valueChangeListener);
                                    mctx.addMethodExpressionTargeted(innerComponent, attributeName, valueChangeListener);
                                    if (mctx.isUsingPSSOnThisView() && mctx.isMarkInitialState())
                                    {
                                        innerComponent.markInitialState();
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        // composite:attribute targets property only has sense for action, actionListener,
                        // validator or valueChangeListener. This means we have to retarget the method expression
                        // to the topLevelComponent.

                        // Since a MethodExpression has no state, we can use it multiple times without problem, so
                        // first create it here.
                        methodSignature = methodSignature.trim();
                        methodExpression = context.getApplication().getExpressionFactory().
                                createMethodExpression(elContext,
                                        attributeExpressionString, _getReturnType(methodSignature),
                                        _getParameters(methodSignature));

                        methodExpression = reWrapMethodExpression(methodExpression, attributeNameValueExpression);

                        UIComponent topLevelComponentBase = topLevelComponent.getFacet(UIComponent.COMPOSITE_FACET_NAME);

                        for (String target : targetsArray)
                        {
                            UIComponent innerComponent = ComponentSupport.findComponentChildOrFacetFrom(context, topLevelComponentBase, target);

                            if (innerComponent == null)
                            {
                                continue;
                            }

                            // If a component is found, that means the expression should be retarget to the
                            // components related
                            if (isCompositeComponentRetarget(context, innerComponent, attributeName))
                            {
                                innerComponent.getAttributes().put(attributeName, attributeNameValueExpression);

                                mctx.clearMethodExpressionAttribute(innerComponent, attributeName);

                                retargetMethodExpressions(context, innerComponent);
                                if (mctx.isUsingPSSOnThisView() && mctx.isMarkInitialState())
                                {
                                    innerComponent.markInitialState();
                                }
                            }
                            else
                            {
                                //Put the retarget
                                if (ccAttrMeRedirection)
                                {
                                    // Since we require here a method expression, it is necessary to wrap the ValueExpression
                                    // into a MethodExpression that handles redirection.
                                    innerComponent.getAttributes().put(attributeName, new ValueExpressionMethodExpression(attributeNameValueExpression));
                                }
                                else
                                {
                                    innerComponent.getAttributes().put(attributeName, methodExpression);
                                }
View Full Code Here

                                                    attributeExpressionString, null, EMPTY_CLASS_ARRAY), attributeNameValueExpression);
                                   
                                    // If it is a redirection, a wrapper is used to locate the right instance and call it properly.
                                    if (ccAttrMeRedirection)
                                    {
                                        ((ActionSource2)innerComponent).setActionExpression(new ValueExpressionMethodExpression(attributeNameValueExpression));
                                    }
                                    else
                                    {
                                        ((ActionSource2)innerComponent).setActionExpression(methodExpression);
                                    }
                                }
                                else if ("actionListener".equals(attributeName))
                                {
                                    //First try to remove any prevous target if any
                                    ActionListener o = (ActionListener) mctx.removeMethodExpressionTargeted(innerComponent, attributeName);
                                    if (o != null)
                                    {
                                        ((ActionSource2)innerComponent).removeActionListener(o);
                                    }
                                   
                                    // target is ActionSource2
                                    ActionListener actionListener = null;
                                    // If it is a redirection, a wrapper is used to locate the right instance and call it properly.
                                    if (ccAttrMeRedirection)
                                    {
                                        actionListener = new RedirectMethodExpressionValueExpressionActionListener(attributeNameValueExpression);
                                    }
                                    else
                                    {
                                        methodExpression = reWrapMethodExpression(context.getApplication().getExpressionFactory().
                                                createMethodExpression(elContext,
                                                        attributeExpressionString, Void.TYPE, ACTION_LISTENER_SIGNATURE), attributeNameValueExpression);

                                        methodExpression2 = reWrapMethodExpression(context.getApplication().getExpressionFactory().
                                            createMethodExpression(elContext,
                                                    attributeExpressionString, Void.TYPE, EMPTY_CLASS_ARRAY), attributeNameValueExpression);

                                        actionListener = new MethodExpressionActionListener(methodExpression, methodExpression2);
                                    }
                                    ((ActionSource2)innerComponent).addActionListener(actionListener);
                                    mctx.addMethodExpressionTargeted(innerComponent, attributeName, actionListener);
                                }
                                else if ("validator".equals(attributeName))
                                {
                                   //First try to remove any prevous target if any
                                    Validator o = (Validator) mctx.removeMethodExpressionTargeted(innerComponent, attributeName);
                                    if (o != null)
                                    {
                                        ((EditableValueHolder)innerComponent).removeValidator(o);
                                    }
                                   
                                    // target is EditableValueHolder
                                    Validator validator = null;
                                    // If it is a redirection, a wrapper is used to locate the right instance and call it properly.
                                    if (ccAttrMeRedirection)
                                    {
                                        validator = new RedirectMethodExpressionValueExpressionValidator(attributeNameValueExpression);
                                    }
                                    else
                                    {
                                        methodExpression = reWrapMethodExpression(context.getApplication().getExpressionFactory().
                                                createMethodExpression(elContext,
                                                    attributeExpressionString, Void.TYPE,
                                                    VALIDATOR_SIGNATURE), attributeNameValueExpression);
           
                                        validator = new MethodExpressionValidator(methodExpression);
                                    }
                                    ((EditableValueHolder)innerComponent).addValidator( validator );
                                    mctx.addMethodExpressionTargeted(innerComponent, attributeName, validator);
                                }
                                else if ("valueChangeListener".equals(attributeName))
                                {
                                    ValueChangeListener o = (ValueChangeListener) mctx.removeMethodExpressionTargeted(innerComponent, attributeName);
                                    if (o != null)
                                    {
                                        ((EditableValueHolder)innerComponent).removeValueChangeListener(o);
                                    }
                                   
                                    // target is EditableValueHolder
                                    ValueChangeListener valueChangeListener = null;
                                    // If it is a redirection, a wrapper is used to locate the right instance and call it properly.
                                    if (ccAttrMeRedirection)
                                    {
                                        valueChangeListener = new RedirectMethodExpressionValueExpressionValueChangeListener(attributeNameValueExpression);
                                    }
                                    else
                                    {
                                        methodExpression = reWrapMethodExpression(context.getApplication().getExpressionFactory().
                                                createMethodExpression(elContext,
                                                        attributeExpressionString, Void.TYPE,
                                                        VALUE_CHANGE_LISTENER_SIGNATURE), attributeNameValueExpression);
           
                                        methodExpression2 = reWrapMethodExpression(context.getApplication().getExpressionFactory().
                                                createMethodExpression(elContext,
                                                        attributeExpressionString, Void.TYPE,
                                                        EMPTY_CLASS_ARRAY), attributeNameValueExpression);
           
                                        valueChangeListener = new MethodExpressionValueChangeListener(methodExpression, methodExpression2);
                                    }
                                    ((EditableValueHolder)innerComponent).addValueChangeListener( valueChangeListener );
                                    mctx.addMethodExpressionTargeted(innerComponent, attributeName, valueChangeListener);
                                }
                            }
                        }
                    }
                    else
                    {
                        // composite:attribute targets property only has sense for action, actionListener,
                        // validator or valueChangeListener. This means we have to retarget the method expression
                        // to the topLevelComponent.

                        // Since a MethodExpression has no state, we can use it multiple times without problem, so
                        // first create it here.
                        methodSignature = methodSignature.trim();
                        methodExpression = context.getApplication().getExpressionFactory().
                                createMethodExpression(elContext,
                                        attributeExpressionString, _getReturnType(methodSignature),
                                        _getParameters(methodSignature));
                       
                        methodExpression = reWrapMethodExpression(methodExpression, attributeNameValueExpression);
   
                        UIComponent topLevelComponentBase = topLevelComponent.getFacet(UIComponent.COMPOSITE_FACET_NAME);
                       
                        for (String target : targetsArray)
                        {
                            UIComponent innerComponent = ComponentSupport.findComponentChildOrFacetFrom(context, topLevelComponentBase, target);
                           
                            if (innerComponent == null)
                            {
                                continue;
                            }
                           
                            // If a component is found, that means the expression should be retarget to the
                            // components related
                            if (isCompositeComponentRetarget(context, innerComponent, attributeName))
                            {
                                innerComponent.getAttributes().put(attributeName, attributeNameValueExpression);
                               
                                mctx.clearMethodExpressionAttribute(innerComponent, attributeName);
                               
                                retargetMethodExpressions(context, innerComponent);
                            }
                            else
                            {
                                //Put the retarget
                                if (ccAttrMeRedirection)
                                {
                                    // Since we require here a method expression, it is necessary to wrap the ValueExpression
                                    // into a MethodExpression that handles redirection.
                                    innerComponent.getAttributes().put(attributeName, new ValueExpressionMethodExpression(attributeNameValueExpression));
                                }
                                else
                                {
                                    innerComponent.getAttributes().put(attributeName, methodExpression);
                                }
View Full Code Here

                    throw new ELException("Cannot add parameters to a MethodExpression "
                            + "pointing to cc.attrs");
                }
               
                ValueExpression valueExpr = this.getValueExpression(ctx, Object.class);
                methodExpression = new ValueExpressionMethodExpression(valueExpr);
            }
            else
            {
                ExpressionFactory f = ctx.getExpressionFactory();
                methodExpression = f.createMethodExpression(ctx, this.value, type, paramTypes);
View Full Code Here

                                                    attributeExpressionString, null, EMPTY_CLASS_ARRAY), attributeNameValueExpression);
                                   
                                    // If it is a redirection, a wrapper is used to locate the right instance and call it properly.
                                    if (ccAttrMeRedirection)
                                    {
                                        ((ActionSource2)innerComponent).setActionExpression(new ValueExpressionMethodExpression(attributeNameValueExpression));
                                    }
                                    else
                                    {
                                        ((ActionSource2)innerComponent).setActionExpression(methodExpression);
                                    }
                                }
                                else if ("actionListener".equals(targetAttributeName))
                                {
                                    //First try to remove any prevous target if any
                                    ActionListener o = (ActionListener) mctx.removeMethodExpressionTargeted(innerComponent, targetAttributeName);
                                    if (o != null)
                                    {
                                        ((ActionSource2)innerComponent).removeActionListener(o);
                                    }
                                   
                                    // target is ActionSource2
                                    ActionListener actionListener = null;
                                    // If it is a redirection, a wrapper is used to locate the right instance and call it properly.
                                    if (ccAttrMeRedirection)
                                    {
                                        actionListener = new RedirectMethodExpressionValueExpressionActionListener(attributeNameValueExpression);
                                    }
                                    else
                                    {
                                        methodExpression = reWrapMethodExpression(context.getApplication().getExpressionFactory().
                                                createMethodExpression(elContext,
                                                        attributeExpressionString, Void.TYPE, ACTION_LISTENER_SIGNATURE), attributeNameValueExpression);

                                        methodExpression2 = reWrapMethodExpression(context.getApplication().getExpressionFactory().
                                            createMethodExpression(elContext,
                                                    attributeExpressionString, Void.TYPE, EMPTY_CLASS_ARRAY), attributeNameValueExpression);

                                        actionListener = new MethodExpressionActionListener(methodExpression, methodExpression2);
                                    }
                                    ((ActionSource2)innerComponent).addActionListener(actionListener);
                                    mctx.addMethodExpressionTargeted(innerComponent, targetAttributeName, actionListener);
                                }
                                else if ("validator".equals(targetAttributeName))
                                {
                                   //First try to remove any prevous target if any
                                    Validator o = (Validator) mctx.removeMethodExpressionTargeted(innerComponent, targetAttributeName);
                                    if (o != null)
                                    {
                                        ((EditableValueHolder)innerComponent).removeValidator(o);
                                    }
                                   
                                    // target is EditableValueHolder
                                    Validator validator = null;
                                    // If it is a redirection, a wrapper is used to locate the right instance and call it properly.
                                    if (ccAttrMeRedirection)
                                    {
                                        validator = new RedirectMethodExpressionValueExpressionValidator(attributeNameValueExpression);
                                    }
                                    else
                                    {
                                        methodExpression = reWrapMethodExpression(context.getApplication().getExpressionFactory().
                                                createMethodExpression(elContext,
                                                    attributeExpressionString, Void.TYPE,
                                                    VALIDATOR_SIGNATURE), attributeNameValueExpression);
           
                                        validator = new MethodExpressionValidator(methodExpression);
                                    }
                                    ((EditableValueHolder)innerComponent).addValidator( validator );
                                    mctx.addMethodExpressionTargeted(innerComponent, targetAttributeName, validator);
                                }
                                else if ("valueChangeListener".equals(targetAttributeName))
                                {
                                    ValueChangeListener o = (ValueChangeListener) mctx.removeMethodExpressionTargeted(innerComponent, targetAttributeName);
                                    if (o != null)
                                    {
                                        ((EditableValueHolder)innerComponent).removeValueChangeListener(o);
                                    }
                                   
                                    // target is EditableValueHolder
                                    ValueChangeListener valueChangeListener = null;
                                    // If it is a redirection, a wrapper is used to locate the right instance and call it properly.
                                    if (ccAttrMeRedirection)
                                    {
                                        valueChangeListener = new RedirectMethodExpressionValueExpressionValueChangeListener(attributeNameValueExpression);
                                    }
                                    else
                                    {
                                        methodExpression = reWrapMethodExpression(context.getApplication().getExpressionFactory().
                                                createMethodExpression(elContext,
                                                        attributeExpressionString, Void.TYPE,
                                                        VALUE_CHANGE_LISTENER_SIGNATURE), attributeNameValueExpression);
           
                                        methodExpression2 = reWrapMethodExpression(context.getApplication().getExpressionFactory().
                                                createMethodExpression(elContext,
                                                        attributeExpressionString, Void.TYPE,
                                                        EMPTY_CLASS_ARRAY), attributeNameValueExpression);
           
                                        valueChangeListener = new MethodExpressionValueChangeListener(methodExpression, methodExpression2);
                                    }
                                    ((EditableValueHolder)innerComponent).addValueChangeListener( valueChangeListener );
                                    mctx.addMethodExpressionTargeted(innerComponent, targetAttributeName, valueChangeListener);
                                }
                            }
                        }
                    }
                    else
                    {
                        // composite:attribute targets property only has sense for action, actionListener,
                        // validator or valueChangeListener. This means we have to retarget the method expression
                        // to the topLevelComponent.

                        // Since a MethodExpression has no state, we can use it multiple times without problem, so
                        // first create it here.
                        methodSignature = methodSignature.trim();
                        methodExpression = context.getApplication().getExpressionFactory().
                                createMethodExpression(elContext,
                                        attributeExpressionString, _getReturnType(methodSignature),
                                        _getParameters(methodSignature));
                       
                        methodExpression = reWrapMethodExpression(methodExpression, attributeNameValueExpression);
   
                        UIComponent topLevelComponentBase = topLevelComponent.getFacet(UIComponent.COMPOSITE_FACET_NAME);
                       
                        for (String target : targetsArray)
                        {
                            UIComponent innerComponent = ComponentSupport.findComponentChildOrFacetFrom(context, topLevelComponentBase, target);
                           
                            if (innerComponent == null)
                            {
                                continue;
                            }
                           
                            // If a component is found, that means the expression should be retarget to the
                            // components related
                            if (isCompositeComponentRetarget(context, innerComponent, targetAttributeName))
                            {
                                innerComponent.getAttributes().put(targetAttributeName, attributeNameValueExpression);
                               
                                mctx.clearMethodExpressionAttribute(innerComponent, targetAttributeName);
                               
                                retargetMethodExpressions(context, innerComponent);
                            }
                            else
                            {
                                //Put the retarget
                                if (ccAttrMeRedirection)
                                {
                                    // Since we require here a method expression, it is necessary to wrap the ValueExpression
                                    // into a MethodExpression that handles redirection.
                                    innerComponent.getAttributes().put(targetAttributeName, new ValueExpressionMethodExpression(attributeNameValueExpression));
                                }
                                else
                                {
                                    innerComponent.getAttributes().put(targetAttributeName, methodExpression);
                                }
View Full Code Here

TOP

Related Classes of org.apache.myfaces.view.facelets.el.ValueExpressionMethodExpression

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.