First we need to add an button on the page with an actionlistener
<af:commandButton text="Revert Changes" actionListener="#{MainBean.revertCategories}"/>
In this backing bean method we can reset the ADF bindings. Use this code to requery all the iterators in the pagedef.
public void revertCategories(ActionEvent actionEvent) {
dc.refreshControl();
DCIteratorBinding iterBind= (DCIteratorBinding)dc.get("queryCategoryFindAllIterator");
iterBind.executeQuery();
iterBind.refresh(DCIteratorBinding.RANGESIZE_UNLIMITED);
}
Resetting inputtext items based on values in a backing bean can be tricky especially when a user has changed an inputtext component. In that case you can try to reset this value from the backing bean, but it may not work because the submittedValue of the uicomponent with the user input is still set. We need to reset the inputtext uicomponent and add partial trigger to it. Here is the code to do this. This method has as input parameter the backing bean binding of a form or an other higher uicomponent. This method will reset all the childern uicomponents who are not disabled.
private void resetValueInputItems(AdfFacesContext adfFacesContext, UIComponent component){
List<UIComponent> items = component.getChildren();
for ( UIComponent item : items ) {
resetValueInputItems(adfFacesContext,item);
if ( item instanceof RichInputText ) {
RichInputText input = (RichInputText)item;
if ( !input.isDisabled() ) {
input.resetValue() ;
adfFacesContext.addPartialTarget(input);
};
} else if ( item instanceof RichInputDate ) {
RichInputDate input = (RichInputDate)item;
if ( !input.isDisabled() ) {
input.resetValue() ;
adfFacesContext.addPartialTarget(input);
};
}
}
}
public void resetForm(ActionEvent actionEvent) {
AdfFacesContext adfFacesContext = AdfFacesContext.getCurrentInstance();
resetValueInputItems(adfFacesContext,vvFormBinding );
testMap.put("TEST", "initial value");
}
Thanks very much - worked for me in 10.1.3.4.0.
ReplyDeleteDon
Can you please explain what dc refers here?
ReplyDeleteThanks
What is dc and how to create it?????
ReplyDeleteHi,
ReplyDeleteyou are right that is
DCBindingContainer dcBindings = ADFUtils.getDCBindingContainer();
dcBindings.resetInputState();
dcBindings.refreshControl();
hope this helps
Why not use BindingContext.getCurrent().getCurrentBindingsEntry() rather than ADFUtils which is not available unless you create it or copy it from somewhere.
ReplyDeletevvFormBinding
ReplyDeletehow to create this ?
public void TstActionListeners(ActionEvent actionEvent) {
ReplyDelete// Add event code here...
DCBindingContainer dcBindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
dcBindings.resetInputState();
dcBindings.refreshControl();
DCIteratorBinding iterBind= (DCIteratorBinding)dcBindings.get("GlLvlAccountsS1VO1Iterators");
iterBind.executeQuery();
iterBind.refresh(DCIteratorBinding.RANGESIZE_UNLIMITED);
}
Caused by: java.sql.SQLException: ORA-01427: single-row subquery returns more than one row
throw some error.
can you mail you this examples.
Hi,
ReplyDeletethat is the uicomponent around the inputtext items. like a formLayout etc.
when you lookup the id and retrieve the uicomponent then you have it.
or use the binding attribute on the formlayout and map this to a managed bean with contains the reset code.
thanks
Hi,
ReplyDeleteI have same problem in mobile ADF(Jdeveloper 11g release 2.4).
After submitting values, I am getting same vales in text boxes when I again go to same page by navigation.
In my bean I wrote
ValueExpression veIter =
(ValueExpression)AdfmfJavaUtilities.getValueExpression("#{bindings.DemoBeanIterator}",Object.class);
AmxIteratorBinding iteratorBinding =(AmxIteratorBinding)veIter.getValue(AdfmfJavaUtilities.getAdfELContext());
iteratorBinding.getIterator().refresh();
But the page is not getting refreshed.
I set refresh always to all iterators.
Any help would be appreciated.
Thanks..
Hi
Deletemaybe you can do something with PPR, change event on the iterator and do some ppr on the component around these fields
Thanks
what happen if i set autoSubmit = true on there components ?
ReplyDelete