Java Code Examples for javax.faces.context.FacesContext.getELContext()

The following are Jave code examples for showing how to use getELContext() of the javax.faces.context.FacesContext class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: myfaces-trinidad   File: ImmutableItemNode.java   Source Code and License Vote up 6 votes
public void actionListener(ActionEvent event)
{
  String value = _actionListener;
  if (value != null)
  {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExpressionFactory expressionFactory =
        facesContext.getApplication().getExpressionFactory();
    ELContext context = facesContext.getELContext();

    MethodExpression methodExpression =
        expressionFactory.createMethodExpression(context, value, Void.TYPE,
            new Class<?>[]
            { ActionEvent.class });
    methodExpression.invoke(context, new Object[]
    { event });
  }

}
 
Example 2
Project: myfaces-trinidad   File: ImmutableItemNode.java   Source Code and License Vote up 6 votes
public String doAction()
{
  String value = _action;

  if (value != null)
  {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExpressionFactory expressionFactory =
        facesContext.getApplication().getExpressionFactory();
    ELContext context = facesContext.getELContext();
    MethodExpression methodExpression =
        expressionFactory.createMethodExpression(context, value,
            String.class, new Class<?>[]
            {});
    value = (String) methodExpression.invoke(context, null);
  }

  // Post me as the selected Node for the request
  postSelectedNode(this);

  return value;
}
 
Example 3
Project: myfaces-trinidad   File: ItemNode.java   Source Code and License Vote up 6 votes
/**
  * Gets the value of the node's action property.  The action attr value
  * could be one of 2 things:
  * 1) An EL expression
  * 2) An outcome referencing a navigation rule in the faces_config file.
  * 
  * Since this method is called only when an ItemNode is clicked, the model 
  * is notified that this node is the currently selected node.
  * 
  * @return String value of the ItemNode's "action" property.
  */
@Override
public String doAction()
{
  String value = _action;

  if (value != null)
  {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExpressionFactory expressionFactory =
        facesContext.getApplication().getExpressionFactory();
    ELContext context = facesContext.getELContext();
    MethodExpression methodExpression =
        expressionFactory.createMethodExpression(context, value,
            String.class, new Class<?>[]
            {});
    value = (String) methodExpression.invoke(context, null);
  }

  // Post me as the selected Node for the request
  postSelectedNode(this);

  return value;
}
 
Example 4
Project: myfaces-trinidad   File: ItemNode.java   Source Code and License Vote up 6 votes
public void actionListener(ActionEvent event)
{
  String value = _actionListener;
  if (value != null)
  {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExpressionFactory expressionFactory =
        facesContext.getApplication().getExpressionFactory();
    ELContext context = facesContext.getELContext();

    MethodExpression methodExpression =
        expressionFactory.createMethodExpression(context, value, Void.TYPE,
            new Class<?>[]
            { ActionEvent.class });
    methodExpression.invoke(context, new Object[]{ event });
  }

}
 
Example 5
Project: myfaces-trinidad   File: ImmutableItemNode.java   Source Code and License Vote up 6 votes
public void actionListener(ActionEvent event)
{
  String value = _actionListener;
  if (value != null)
  {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExpressionFactory expressionFactory =
        facesContext.getApplication().getExpressionFactory();
    ELContext context = facesContext.getELContext();

    MethodExpression methodExpression =
        expressionFactory.createMethodExpression(context, value, Void.TYPE,
            new Class<?>[]
            { ActionEvent.class });
    methodExpression.invoke(context, new Object[]
    { event });
  }

}
 
Example 6
Project: myfaces-trinidad   File: ImmutableItemNode.java   Source Code and License Vote up 6 votes
public String doAction()
{
  String value = _action;

  if (value != null)
  {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExpressionFactory expressionFactory =
        facesContext.getApplication().getExpressionFactory();
    ELContext context = facesContext.getELContext();
    MethodExpression methodExpression =
        expressionFactory.createMethodExpression(context, value,
            String.class, new Class<?>[]
            {});
    value = (String) methodExpression.invoke(context, null);
  }

  // Post me as the selected Node for the request
  postSelectedNode(this);

  return value;
}
 
Example 7
Project: myfaces-trinidad   File: ItemNode.java   Source Code and License Vote up 6 votes
/**
  * Gets the value of the node's action property.  The action attr value
  * could be one of 2 things:
  * 1) An EL expression
  * 2) An outcome referencing a navigation rule in the faces_config file.
  * 
  * Since this method is called only when an ItemNode is clicked, the model 
  * is notified that this node is the currently selected node.
  * 
  * @return String value of the ItemNode's "action" property.
  */
@Override
public String doAction()
{
  String value = _action;

  if (value != null)
  {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExpressionFactory expressionFactory =
        facesContext.getApplication().getExpressionFactory();
    ELContext context = facesContext.getELContext();
    MethodExpression methodExpression =
        expressionFactory.createMethodExpression(context, value,
            String.class, new Class<?>[]
            {});
    value = (String) methodExpression.invoke(context, null);
  }

  // Post me as the selected Node for the request
  postSelectedNode(this);

  return value;
}
 
Example 8
Project: myfaces-trinidad   File: ItemNode.java   Source Code and License Vote up 6 votes
public void actionListener(ActionEvent event)
{
  String value = _actionListener;
  if (value != null)
  {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExpressionFactory expressionFactory =
        facesContext.getApplication().getExpressionFactory();
    ELContext context = facesContext.getELContext();

    MethodExpression methodExpression =
        expressionFactory.createMethodExpression(context, value, Void.TYPE,
            new Class<?>[]
            { ActionEvent.class });
    methodExpression.invoke(context, new Object[]{ event });
  }

}
 
Example 9
Project: myfaces-trinidad   File: LazyValueExpression.java   Source Code and License Vote up 5 votes
private static ELContext _getELContext(Application application)
{
  FacesContext fContext = FacesContext.getCurrentInstance();

  if (fContext != null)
  {
    return fContext.getELContext();
  }
  else
  {
    // use a dummy ELContext if FacesContext is null
    return new MockELContext(application);
  }
}
 
Example 10
Project: myfaces-trinidad   File: SortableModel.java   Source Code and License Vote up 5 votes
static private ELContext _getELContext(
  FacesContext context, ELResolver resolver)
{
  // Hopefully, we have a FacesContext.  If not, we're
  // going to have to synthesize one!
  if (context != null)
    return context.getELContext();

  return new ELContextImpl(resolver);
}
 
Example 11
Project: Android_Code_Arbiter   File: ElExpressionSample.java   Source Code and License Vote up 5 votes
public void unsafeEL(String expression) {
    FacesContext context = FacesContext.getCurrentInstance();
    ExpressionFactory expressionFactory = context.getApplication().getExpressionFactory();
    ELContext elContext = context.getELContext();
    ValueExpression vex = expressionFactory.createValueExpression(elContext, expression, String.class);
    String result = (String) vex.getValue(elContext);
    System.out.println(result);
}
 
Example 12
Project: Android_Code_Arbiter   File: ElExpressionSample.java   Source Code and License Vote up 5 votes
public void safeEL() {
    FacesContext context = FacesContext.getCurrentInstance();
    ExpressionFactory expressionFactory = context.getApplication().getExpressionFactory();
    ELContext elContext = context.getELContext();
    ValueExpression vex = expressionFactory.createValueExpression(elContext, "1+1", String.class);
    String result = (String) vex.getValue(elContext);
    System.out.println(result);
}