Navigation with popup

The creation of popups varies according to the JSF implementation that we use for each project. Each implementation gives to us the option to create popups modals or non modals. Today we are going to speak on popups in ADF, which are modals.

In order to create popup in ADF, we must define a rule of specific navigation, which will open the new window in form of popup, for it, in the file faces-config.xml we must write the following thing:

    <navigation-rule>
        <from-view-id>/ejemplo1.jspx</from-view-id>
        <navigation-case>
              <from-outcome>dialog:abrirPopup</from-outcome>
              <to-view-id>/ejemplo2.jsxp</to-view-id>
        </navigation-case>
    </navigation-rule>

Like any other rule of navigation, when executing a method and giving back a string like “dialog: abrirPopup” will redirect us to this page, but this time like a popup.

The case can be given that we want to pass values to the new page which we are opening, because equally that would happen if not outside popup, we would have to call to the static class AdfFacesContext and to do the following thing in our method associated to action:

    AdfFacesContext().getCurrentInstance().getProcessScope().put ( " key " , " objeto " );

If we want to get from the backing_bean these values would be made in the same way, but instead of set the values we would gather them:

    AdfFacesContext().getCurrentInstance().getProcessScope().get( " key " );

The only thing that we would have left to do would be to associate a property to him to the button that is going to open popup:

    useWindow = true;

This way we would have created simple popup in our page. Average ones exist other to be able to pass values to him to popup, and would be associating an event to him of type launchEvent to the button, and the only thing that would be to do is to capture the component and to pass the values to him of way to similiar to since we have explained previously. The problem to this is that sometimes, we want that according to that type of condition is made in the method associated to the event makes a navigation or another one, or that does not open any popup.

It can happen that we have in the event a condition that according to the size of a list, is sent to popup certain values to him, our intention would be that if that list is empty not sends popup but that is sent a message to the FacesContext. The parameters would be associated acceding to launchEvent, gathering the component and executing the method getDialogParameters().put (…);

To the same time, this being associated action to the button that sends popup, that would be executed before the previous event, therefore, is already settling down the string that is due to return to send popup (dialog: …).

If case gave us that not we must to send popup, we commanded message of error to FacesContext, would appear painted in screen, but since the navigation rule has been defined before the event is executed, is also opened to us popup.

The solution to the problem would be to eliminate that launchEvent and to execute the logic in action, and the values of popup of passing them through AdfFacesContext as we explain at the beginning of the tutorial.

Tags:

Comments are closed.