In order to
commit transactions belongs to two data controls with a single commit button in
a JSF page.
First we have to get the DataControlFrame
object which can access all the data
controls in the particular application
public void onCommit(ActionEvent
actionEvent) {
// Add event code here...
BindingContext bc=BindingContext.getCurrent();
DataControlFrame
dcf=bc.findDataControlFrame(bc.getCurrentDataControlFrame());
Collection<DCDataControl> dccol=dcf.datacontrols();
for(DCDataControl dCDatacontrol : dccol){
if(dCDatacontrol.isTransactionDirty()){
try{
dCDatacontrol.commitTransaction();
}catch(Exception e){
FacesContext
fc=FacesContext.getCurrentInstance();
fc.addMessage(null,new
FacesMessage(FacesMessage.SEVERITY_ERROR,e.getMessage(),null));
e.printStackTrace();
}
}
}
}
No comments:
Post a Comment