Wednesday, October 28, 2009

How To Get Application Module From Your BackingBean

There are two ways to generate application module from your backnigbean:

1- Get application module from iterator:
BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
DCIteratorBinding dciter = (DCIteratorBinding)bindings.get("YourView1Iterator");
ApplicationModule am=dciter.getViewObject().getApplicationModule();
--------------------------------------------------------------
2- ApplicationModule am = this.getAm();
private ApplicationModule getAm() {
FacesContext fc = FacesContext.getCurrentInstance();
Application app = fc.getApplication();
ExpressionFactory elFactory = app.getExpressionFactory();
ELContext elContext = fc.getELContext();
ValueExpression valueExp =
elFactory.createValueExpression(elContext, "#{data.AppModuleDataControl.dataProvider}",
Object.class);
return (ApplicationModule )valueExp.getValue(elContext);
}

No comments:

Post a Comment