Close the containing parent popup component without binding using an actionEvent

When using popups in ADF we suffered the problem to close the popup after finishing the activity.
So this is the request: We have a table providing data with an info facet holding buttons for adding, editing and deleting a selected row. While the add and edit button open a popup with a form the delete button opens a dialog to confirm the delete action. This is realized with a showPopupBeavior. Of course there is a cancel button in all of these popups closing it immediately and rolling back. popup

So this is an example what a popup might look like.

As the cancel button immediately rollbacks, the save button immediately commits the made changes.

delete

This is the delete popup

This cancel button is just out of the box, closing the dialog and not rolling back because there is nothing to rollback. But delete executes this action, commits and closes the dialog.

How is this implemented?

Every button has an actionListener property which we will use. After completing out task in the code before we will call a closePopup method.

public void closePopup(ActionEvent actionEvent) {

UIComponent tmpComponent;

tmpComponent = actionEvent.getComponent().getParent();

while (!(tmpComponent instanceof RichPopup)) {

tmpComponent = tmpComponent.getParent();

}

RichPopup popup = (RichPopup) tmpComponent;

popup.hide();

}

So we are going the parent of the calling component until we hit an UIComponent, which is an instance of a RichPopup we can close.

What’s the advantage of this?

First of all this code is reusable for every situation where we want to close the parent popup.

Secondly it’s irrespective of binding the component to the bean.

Even though we did not experience problems with this technique closing the popup, we are not aware of following problems. If you know some issues that may appear, please let us know in the comments!

Dieser Beitrag wurde unter BPM & System Integration, Software Engineering abgelegt und mit , , , , , , , , verschlagwortet. Setze ein Lesezeichen auf den Permalink.

Eine Antwort zu Close the containing parent popup component without binding using an actionEvent

  1. Pingback: WebLogic & Developer Partner Community Newsletter February 2016 | WebLogic Community

Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

WordPress.com-Logo

Du kommentierst mit Deinem WordPress.com-Konto. Abmelden / Ändern )

Twitter-Bild

Du kommentierst mit Deinem Twitter-Konto. Abmelden / Ändern )

Facebook-Foto

Du kommentierst mit Deinem Facebook-Konto. Abmelden / Ändern )

Google+ Foto

Du kommentierst mit Deinem Google+-Konto. Abmelden / Ändern )

Verbinde mit %s