Monday, April 29, 2013

Open and Close Popup on pageload using javascript ADF

  <f:view>


<af:document id="d1" title="Report">
     <af:resource type="javascript">

            function openPopup() {
            var popup = AdfPage.PAGE.findComponentByAbsoluteId('p1');
            popup.show();
            var timeOutPeriod = 50 * 1000; // 50 sec
             setTimeout(function closePopup(){popup.hide();}, timeOutPeriod);
                     }
              </af:resource>

  <af:clientListener type="load" method="openPopup"/>
   
<af:form id="f1">
      
  <af:popup id="p1" contentDelivery="immediate">

<af:dialog id="d2" type="none" title="Report is currently being generated..."
closeIconVisible="false" clientComponent="true">
<af:panelGroupLayout id="pgl1" layout="vertical" halign="center">
<af:image source="/images/reportgen.JPG" id="i1"/>
<af:image source="/images/animbar.gif" id="i2"
inlineStyle="width:120px;"/>
<af:outputText value="... please wait" id="ot11"/>
</af:panelGroupLayout>
</af:dialog>

</af:popup>


</af:form>
   
    </af:document>

 </f:view>


  alert("This is a test");
 alert(popup); //this shows the id of the popup
if the below code doesn't work, you can find the right popId by displaying the popup id using alert command
var popup = AdfPage.PAGE.findComponentByAbsoluteId('p1'); 

No comments: