如何通过托管bean以编程方式提交?

时间:2019-07-02 20:18:04

标签: oracle-adf

我有一个托管Bean,它可以更改属性值并调用弹出窗口。 我还需要提交所做的更改(不必单击提交按钮),我尝试了一些代码,但是它什么也没做。 请帮帮我。

DCBindingContainer bindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
OperationBinding operationBinding = bindings.getOperationBinding("Commit");
operationBinding.execute();

1 个答案:

答案 0 :(得分:0)

您可以使用以下函数以编程方式提交对Iterator的更改(例如,在动作侦听器中):

public static ViewObjectImpl getViewObjectFromIterator(String nomIterator) {
    ViewObjectImpl returnVO = null;
    DCBindingContainer dcb = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
    if (dcb != null) {
        DCIteratorBinding iter = dcb.findIteratorBinding(nomIterator);
        if (iter != null) {
            returnVO = (ViewObjectImpl)iter.getViewObject();
        }
    }
    return returnVO;
}

private void commit(String IteratorName) {
    ViewObject vo = this.getViewObjectFromIterator(IteratorName);
    try {
        vo.getApplicationModule().getTransaction().validate();
        vo.getApplicationModule().getTransaction().commit();
    } catch (ValidationException e) {
        String validationErrorMessage = e.getDetailMessage();
        //Occur when some committed data is rejected due to validation error.
        //log it : log(Level.WARNING, " " + validationErrorMessage);
    }
    catch (Exception e) {
        //Log it and warn something unexpected occured
    }


}

//In your action listener simply call the commit function as follow
//You can Find YOUR_ITERATOR_NAME the your PageDef Binding file in the Executables Column
commit("YOUR_ITERATOR_NAME");

查看更多:https://gist.github.com/CedricL46/04570c1f078583321ad680ee8ba28f72