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.

[code language=“java“]public void closePopup(ActionEvent actionEvent) {

UIComponent tmpComponent;

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

while (!(tmpComponent instanceof RichPopup)) {

tmpComponent = tmpComponent.getParent();

}

RichPopup popup = (RichPopup) tmpComponent;

popup.hide();

}[/code]
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!

Alle Beiträge von Marvin Muuß

Schreibe einen Kommentar