Example usage for javax.el ExpressionFactory createMethodExpression

List of usage examples for javax.el ExpressionFactory createMethodExpression

Introduction

In this page you can find the example usage for javax.el ExpressionFactory createMethodExpression.

Prototype

public abstract MethodExpression createMethodExpression(ELContext context, String expression,
        Class<?> expectedReturnType, Class<?>[] expectedParamTypes);

Source Link

Document

Create a new method expression instance.

Usage

From source file:org.nuxeo.ecm.platform.ui.web.tag.handler.DocumentLinkTagHandler.java

/**
 * Sets action after component has been created.
 *///from   ww  w. j av  a  2 s .  co  m
@Override
public void onComponentCreated(FaceletContext ctx, UIComponent c, UIComponent parent) {
    if (c instanceof ActionSource2) {
        ActionSource2 command = (ActionSource2) c;
        String docValue = getDocumentValue();
        String viewId = getViewValue();
        String actionValue;
        if (viewId == null) {
            actionValue = "#{navigationContext.navigateToDocument(" + docValue + ")}";
        } else {
            actionValue = "#{navigationContext.navigateToDocumentWithView(" + docValue + ", " + viewId + ")}";
        }
        FacesContext facesContext = ctx.getFacesContext();
        Application app = facesContext.getApplication();
        ExpressionFactory ef = app.getExpressionFactory();
        ELContext context = facesContext.getELContext();
        MethodExpression action = ef.createMethodExpression(context, actionValue, String.class,
                new Class[] { DocumentModel.class, String.class });
        command.setActionExpression(action);
    }
}

From source file:org.tinygroup.jspengine.runtime.PageContextImpl.java

public static MethodExpression getMethodExpression(String expression, PageContext pageContext,
        FunctionMapper functionMap, Class expectedType, Class[] paramTypes) {

    ELContextImpl elctxt = (ELContextImpl) pageContext.getELContext();
    elctxt.setFunctionMapper(functionMap);
    ExpressionFactory expFactory = getExpressionFactory(pageContext);
    return expFactory.createMethodExpression(elctxt, expression, expectedType, paramTypes);
}