Search This Blog

Monday, March 8, 2010

ADF:- ActionListener

FacesContext context = FacesContext.getCurrentInstance();
ELContext elContext = context .getELContext();
MethodExpression actionListenerExpression = context.getApplication().getExpressionFactory().createMethodExpression(elContext,"#{myHandler.myActionListenerMethod}",null,new Class[] {ActionEvent.class});
MethodExpressionActionListener methodExpressionActionListener = new MethodExpressionActionListener(actionListenerExpression);

ADF:- ActionListener

try
{
Class[] parameterList = { Class.forName("javax.faces.event.ActionEvent") }; MethodBinding actionListenerBinding = FacesContext.getCurrentInstance().getApplication().createMethodBinding( "#{myHandler.myListener}",parameterList); myComponent.setActionListener(actionListenerBinding );
}
catch (Exception e)
{
log.error("error setting ActionListener");
}

ADF:- MethodExpression

FacesContext context = FacesContext.getCurrentInstance();MethodExpression methodEx = context.getApplication().getExpressionFactory().createMethodExpression(context.getELContext(), "#{myHandler.action}", String.class, new Class[] {});
myComponent.setActionExpression(methodEx );

ADF:- MethodBinding

MethodBinding methodBinding = FacesContext.getCurrentInstance().getApplication().createMethodBinding( "#{myHandler.action}",null);
myComponent.setAction( methodBinding );

ADF:- ValueExpression

FacesContext context = FacesContext.getCurrentInstance();
ValueExpression vex = context.getApplication().getExpressionFactory().createValueExpression(context.getELContext(), "#{myBean.myProperty}", String.class);
myComponent.setValueExpression("value", vex);ValueExpression rex = context.getApplication().getExpressionFactory().createValueExpression(context.getELContext(), "#{myBean.myProperty}", Boolean.class);myComponent.setValueExpression("rendered", rex);

ADF:- ValueBinding

ValueBinding vb = FacesContext.getCurrentInstance().getApplication().createValueBinding( "#{myBean.myProperty}");
myComponent.setValueBinding("value", vb);