Thursday, November 17, 2011

Resetting values in popup ADF 11g

If you are using ADF11g version and want to reset the values in the popup, you are not provided with the resetEditableValues option. But you can accomplish this using a custom javascript that i have made.

All you have to do is set clientComponent="true" for all the components that you want to reset and pass the client id of the root component to use this.

var component= AdfPage.PAGE.findComponentByAbsoluteId(clientId);
var components=component.getDescendantComponents();
for (var i=0;i<components.length;i++){
if(components[i] instanceof AdfRichInputText){
if(components[i] instanceof AdfRichSelectOneChoice){

Save the contents of this file to a JS file and then import it in your fragment or a jsf page.

Now you have to bind the parent container like panelFormLayout and then on action of the command button use ExtendedRenderKitService to pass the client id of the root component dynamically to resetAction Method so that this script always works. The snippet is shown below.

* Resets the popup
* @return null
public String resetPopupAction() {
FacesContext context = FacesContext.getCurrentInstance();
ExtendedRenderKitService erks =
Service.getRenderKitService(context, ExtendedRenderKitService.class);
erks.addScript(context,"resetAction('"+formBinding.getClientId(context) +"')");

return null;

Hope this will be helpful :D

No comments:

Post a Comment