Getting unwanted popup "You have not saved your changes. If you close this flow, then your changes will be lost. Do you want to continue?"

66 views Asked by At

Getting this popup every time whenever calling a bean method via valueChangeListener property from SelectOneChoice in a jsff page.

I need help to block this unwanted popup.

SelectOneChoice's property of the .jsff page:

                     <af:selectOneChoice value="................."
                                        label=".................."
                                        required="..............."
                                        shortDesc=".............." 
                                        id="....................."
                                        valueChangeListener="#{TransferWorkAreaBean.onBookLovChange}"
                                        autoSubmit="true">
                       <f:selectItems value="............" id="si2"/>
                       <f:validator binding="......."/>
                    </af:selectOneChoice>

Method in Bean Class::

 public void onBookLovChange(ValueChangeEvent valueChangeEvent) {                 
    valueChangeEvent.getComponent().processUpdates(FacesContext.getCurrentInstance());
    invokeELMethod("#{bindings.methodToExecute.execute}", new Class[0], new Object[0]);
    AdfFacesContext.getCurrentInstance().addPartialTarget(getBusinessTable());
}

Method details of binding Method::

 public void executeInvetoryQueryOnBookChange(String btg) {
        OAViewObjectImpl vo = getBusinessOverview();
        VariableValueManager vvm = vo.ensureVariableManager();
        vvm.setVariableValue("bindBookTypeCode", btg);
        vo.executeQuery();
    }

Please note, in some places I have used encrypted data for policy.

Please also note, that the uncommittedDataWarning property is not ENABLED.

1

There are 1 answers

2
Cedric On

This popup only appear when the option uncommittedDataWarning is set to "on" at the root af:document tag. Try to run a full search in your JDevelopper for "uncommittedDataWarning".

Another way of avoiding this popup in this specific case would be to ensure that your data are committed or rollback in your data model. As the popup only appear if some data aren't committed when a user navigate outside the af:document. You could run something like so right before your

invokeELMethod("#{bindings.methodToExecute.execute}", new Class[0], new Object[0]);

How to commit if needed (https://cedricleruth.com/how-to-programmatically-commit-or-rollback-a-transaction-in-oracle-adf/)

private void commitIfDirty() {
    try {
        ViewObject vo = this.getViewObjectFromIterator("YOUR_ITERATOR_NAME");
        boolean isNotSaved = vo.getApplicationModule()
                               .getTransaction()
                               .isDirty();
        if (isNotSaved) {
            vo.getApplicationModule()
              .getTransaction()
              .validate();
            vo.getApplicationModule()
              .getTransaction()
              .commit();
        }
    } catch (ValidationException validationException) {
        //log it and warn the user that his data isn't valid
    } catch (Exception error) {
        //log it and warn the user something went wrong
    }
}

private 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;
}