In many situation we need to get binding container from our backingbean to execute some of the operation as ( Commit - Rollback - Next - Last - ExecuteWithParam - ............. ) or get your Iterator to get some information as (get Current Row - get ViewObject - get number of row count - refresh iterator - .............. ) There are two way to get your binding container from backingbean :
1- BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
then you can use bindings object to execute some of binding operation as commit operation as:
OperationBinding operationBinding = bindings.getOperationBinding("Commit");
operationBinding.execute();
2- The second way to get binding container is to define a method that return binding container as :
private BindingContainer bindings;
public BindingContainer getBindings() {
if (this.bindings == null) {
FacesContext fc = FacesContext.getCurrentInstance();
this.bindings = (BindingContainer)fc.getApplication().evaluateExpressionGet(fc,"#{bindings}",
BindingContainer.class);
}
return this.bindings;
}
to get binding and execute a commit operation :
BindingContainer bindings = getBindings();
OperationBinding operationBinding = bindings.getOperationBinding("Commit");
Object result = operationBinding.execute();
if (!operationBinding.getErrors().isEmpty()) {
return null;
}
No comments:
Post a Comment