javascripthtmlrichfacesrichfaces-modal

How to check whether the richface pop up panel is visible or not


In following code: code1 onClick function opensUp a RichFace popup panel. i need the onComplete fuction to execute after the closing of the popup. how can i delay the onComplete function. Is there a way to check whether the popup is visible or not as shown in the code2 so that this execution is delayed.

The code1:
<a onclick ="showPopup('popup1')" oncomplete="" > Input </a>

The code2:
<a onclick ="showPopup('popup1'); while(isVisible('popup1')){ }"
oncomplete="" > Input </a>


Solution

  • Just use onhide attribute from rich:popupPanel. The description of it is: The client-side code executed after the popup disappears.

    <h:commandButton value="Call the popup">
        <rich:componentControl target="popup" operation="show" />
    </h:commandButton>
    
    <rich:popupPanel id="popup" modal="true"
        onhide="alert('My popup is now hidden!')"
        onshow="alert('This popup just pop out!');">
        <!-- (... some body ...) -->
    </rich:popupPanel>
    

    If you really want to check in JavaScript if the popup is hidden or visible, then use RichFaces object in JavaScript, find popup and check shown field. An example:

    if (RichFaces.$('MyPopupId').shown) {alert('Shown')} else {alert('Hidden')}
    

    Check RichFaces VDL for more info.