How to display richPopupPanel window from javascript

3.5k views Asked by At

I have one code like below of Rich PopupPanel.

Code:-

<rich:popupPanel id="simplePopup1" autosized="true" width="300"
height="60" moveable="true" resizeable="false" zindex="100"
onmaskclick="#{rich:component('simplePopup1')}.hide()">
<f:facet name="header">
<h: outputText value="Popup" />
</f:facet>
<f:facet name="controls">
<h: outputLink value="#"
    onclick="#{rich:component('simplePopup1')}.hide(); return false;">
X
</h: outputLink>
</f:facet>
<a4j:region>
<a4j: outputPanel ajaxRendered="true">
<h:form ajaxSubmit="true">
<h:panelGrid columns="1">
<a4j:commandLink action="#{popupBean.eventHandler.onClose}"
value="close" immediate="true" />
</h:panelGrid>
</h:form>
</a4j: outputPanel>
</a4j:region>
</rich:popupPanel>

I am able to make this popup visible using the a4j:commandbutton. But instead of that, I want to show this popup window using the javascript code.

Anyone have any idea, how to achieve that.

I have been trying with below code but its not working.

<a4j: outputPanel>
<script type="text/javascript">
javascript:document.getElementById('simplePopup1').style.display = 'none'; //or         javascript:rich:component('simplePopup1')}.show();
</script>
</a4j: outputPanel>

Note:- I am using RF4.0 and JSF2.0 with JBoss6.1 Thanks Jaikrat Singh

2

There are 2 answers

0
Milo van der Zee On

This?:

#{rich:component('simplePopup1')}.show() 

And possibly:

<script>
    function showPopup() {
        #{rich:component('simplePopup1')}.show();
    }
</script>

MAG, Milo van der Zee

1
Mr.B On

Or if you are using external javacript (myscript.js) file you could use:

function openDialog() {
    RichFaces.$("simplePopup1").show();
}