Package com.sun.facelets.el

Examples of com.sun.facelets.el.LegacyMethodBinding


          if (expressionString != null) {
            ExpressionFactory expressionFactory = faceletContext.getExpressionFactory();
            MethodExpression action = new TagMethodExpression(value, expressionFactory.createMethodExpression(
                faceletContext, expressionString, String.class, ComponentUtils.ACTION_ARGS));
            // TODO jsf 1.2
            ((ActionSource) parent).setAction(new LegacyMethodBinding(action));
          }
        } else if ("actionListener".equals(mode.getValue())) {
          String expressionString = value.getValue();
          while (isSimpleExpression(expressionString)) {
            if (isMethodOrValueExpression(expressionString)) {
              ValueExpression expression
                  = faceletContext.getVariableMapper().resolveVariable(removeElParenthesis(expressionString));
              if (expression == null) {
                if (LOG.isDebugEnabled()) {
                  // when the action hasn't been set while using a composition.
                  LOG.debug("Variable can't be resolved: value='" + expressionString + "'");
                }
                expressionString = null;
                break;
              } else {
                expressionString = expression.getExpressionString();
              }
            } else {
              LOG.warn("Only expressions are supported mode=actionListener value='" + expressionString + "'");
              expressionString = null;
              break;
            }
          }
          if (expressionString != null) {
            ExpressionFactory expressionFactory = faceletContext.getExpressionFactory();
            MethodExpression actionListener = new TagMethodExpression(value, expressionFactory.createMethodExpression(
                faceletContext, expressionString, null, ComponentUtils.ACTION_LISTENER_ARGS));
            // TODO jsf 1.2
            ((ActionSource) parent).setActionListener(new LegacyMethodBinding(actionListener));
          }
        } else if ("actionFromValue".equals(mode.getValue())) {
          if (!value.isLiteral()) {
            String result = value.getValue(faceletContext);
            parent.getAttributes().put(name.getValue(), new ConstantMethodBinding(result));
          }
        } else if ("valueIfSet".equals(mode.getValue())) {
          String expressionString = value.getValue();
          String lastExpressionString = null;
          while (isMethodOrValueExpression(expressionString) && isSimpleExpression(expressionString)) {
            ValueExpression expression
                = faceletContext.getVariableMapper().resolveVariable(removeElParenthesis(expressionString));
            if (expression != null) {
              lastExpressionString = expressionString;
              expressionString = expression.getExpressionString();
            } else {
              // restore last value
              expressionString = lastExpressionString;
              break;
            }
          }
          if (expressionString != null) {
            final String attributeName = name.getValue(faceletContext);
            if (containsMethodOrValueExpression(expressionString)) {
              ValueExpression expression = value.getValueExpression(faceletContext, Object.class);
              ELAdaptor.setExpression(parent, attributeName, expression);
            } else {
              final Object literalValue = getValue(faceletContext, parent, expressionString, attributeName);
              parent.getAttributes().put(attributeName, literalValue);
            }
          }
        } else {
          throw new FacesException("Type " + mode + " not supported");
        }
      } else {

        String nameValue = name.getValue(faceletContext);
        if (Attributes.RENDERED.equals(nameValue)) {
          if (value.isLiteral()) {
            parent.setRendered(value.getBoolean(faceletContext));
          } else {
            ELAdaptor.setExpression(parent, nameValue, value.getValueExpression(faceletContext, Boolean.class));
          }
        } else if (Attributes.RENDERED_PARTIALLY.equals(nameValue)
            && parent instanceof SupportsRenderedPartially) {

          if (value.isLiteral()) {
            String[] components = ComponentUtils.splitList(value.getValue());
            ((SupportsRenderedPartially) parent).setRenderedPartially(components);
          } else {
            ELAdaptor.setExpression(parent, nameValue, value.getValueExpression(faceletContext, Object.class));
          }
        } else if (Attributes.STYLE_CLASS.equals(nameValue)) {
          // TODO expression
          ComponentUtils.setStyleClasses(parent, value.getValue());
        } else if (Attributes.MARKUP.equals(nameValue)) {
          if (parent instanceof SupportsMarkup) {
            if (value.isLiteral()) {
              ((SupportsMarkup) parent).setMarkup(Markup.valueOf(value.getValue()));
            } else {
              ValueExpression expression = value.getValueExpression(faceletContext, Object.class);
              ELAdaptor.setExpression(parent, nameValue, expression);
            }
          } else {
            LOG.error("Component is not instanceof SupportsMarkup. Instance is: " + parent.getClass().getName());
          }
        } else if (parent instanceof EditableValueHolder && Attributes.VALIDATOR.equals(nameValue)) {
          MethodExpression methodExpression = getMethodExpression(faceletContext, null, ComponentUtils.VALIDATOR_ARGS);
          if (methodExpression != null) {
            // TODO jsf 1.2
            ((EditableValueHolder) parent).setValidator(new LegacyMethodBinding(methodExpression));
          }
        } else if (parent instanceof EditableValueHolder
            && Attributes.VALUE_CHANGE_LISTENER.equals(nameValue)) {
          MethodExpression methodExpression =
              getMethodExpression(faceletContext, null, ComponentUtils.VALUE_CHANGE_LISTENER_ARGS);
          if (methodExpression != null) {
            // TODO jsf 1.2
            ((EditableValueHolder) parent).setValueChangeListener(new LegacyMethodBinding(methodExpression));
          }
        } else if (parent instanceof ValueHolder && Attributes.CONVERTER.equals(nameValue)) {
          setConverter(faceletContext, parent, nameValue);
        } else if (parent instanceof ActionSource && Attributes.ACTION.equals(nameValue)) {
          MethodExpression action = getMethodExpression(faceletContext, String.class, ComponentUtils.ACTION_ARGS);
          if (action != null) {
            // TODO jsf 1.2
            ((ActionSource) parent).setAction(new LegacyMethodBinding(action));
          }
        } else if (parent instanceof ActionSource && Attributes.ACTION_LISTENER.equals(nameValue)) {
          MethodExpression action = getMethodExpression(faceletContext, null, ComponentUtils.ACTION_LISTENER_ARGS);
          if (action != null) {
            // TODO jsf 1.2
            ((ActionSource) parent).setActionListener(new LegacyMethodBinding(action));
          }
        } else if (!parent.getAttributes().containsKey(nameValue)) {
          if (value.isLiteral()) {
            parent.getAttributes().put(nameValue, value.getValue());
          } else {
View Full Code Here


      this.attribute = attribute;
    }

    public void applyMetadata(FaceletContext ctx, Object instance) {
      ((SortActionSource) instance)
          .setSortActionListener(new LegacyMethodBinding(attribute
              .getMethodExpression(ctx, null,
              SortActionSourceRule.ACTION_LISTENER)));
    }
View Full Code Here

      this.attribute = attribute;
    }

    public void applyMetadata(FaceletContext ctx, Object instance) {
      ((SheetStateChangeSource) instance)
          .setStateChangeListener(new LegacyMethodBinding(attribute
              .getMethodExpression(ctx, null,
              SheetStateChangeSourceRule.ACTION_LISTENER)));
    }
View Full Code Here

      this.attribute = attribute;
    }

    public void applyMetadata(FaceletContext ctx, Object instance) {
      ((TabChangeSource) instance)
          .setTabChangeListener(new LegacyMethodBinding(attribute
              .getMethodExpression(ctx, null,
              TabChangeSourceRule.ACTION_LISTENER)));
    }
View Full Code Here

    public SuggestMethodMapper(TagAttribute attribute) {
      this.attribute = attribute;
    }

    public void applyMetadata(FaceletContext ctx, Object instance) {
      ((UIInput) instance).setSuggestMethod(new LegacyMethodBinding(attribute.getMethodExpression(ctx,
          null, SuggestMethodRule.SUGGEST_METHOD)));
    }
View Full Code Here

      }
     
      MethodExpression me = _method.getMethodExpression(faceletContext,
                                                        Object.class,
                                                        _METHOD_PARAMS);
      listener.setMethod(new LegacyMethodBinding(me));

      ActionSource actionSource = (ActionSource)parent;
      actionSource.addActionListener(listener);
    }
  }
View Full Code Here

        _attribute.getMethodExpression(ctx, null, _paramList);
     
      try
      {
        _method.invoke(instance,
                       new Object[]{new LegacyMethodBinding(expr)});
      }
      catch (InvocationTargetException e)
      {
        throw new TagAttributeException(_attribute, e.getCause());
      }
View Full Code Here

     * @see com.sun.facelets.tag.Metadata#applyMetadata(com.sun.facelets.FaceletContext,
     *      java.lang.Object)
     */
    public void applyMetadata(FaceletContext ctx, Object instance) {
      ((UIDropSupport) instance)
      .setDropListener(new LegacyMethodBinding(this._action
          .getMethodExpression(ctx, null, SIGNATURE)));
    }
View Full Code Here

    /* (non-Javadoc)
     * @see com.sun.facelets.tag.Metadata#applyMetadata(com.sun.facelets.FaceletContext, java.lang.Object)
     */
    public void applyMetadata(FaceletContext ctx, Object instance) {
            ((UIPaint2D) instance)
            .setPaint(new LegacyMethodBinding(this._paint
                    .getMethodExpression(ctx, null,
                            Image2D_ACTION_SIG)));
    }
View Full Code Here

     * @see com.sun.facelets.tag.Metadata#applyMetadata(com.sun.facelets.FaceletContext,
     *      java.lang.Object)
     */
    public void applyMetadata(FaceletContext ctx, Object instance) {
      ((UIDragSupport) instance)
      .setDragListener(new LegacyMethodBinding(this._action
          .getMethodExpression(ctx, null, SIGNATURE)));
    }
View Full Code Here

TOP

Related Classes of com.sun.facelets.el.LegacyMethodBinding

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.