Primefaces使用Javascript打开一个p:对话框

Primefaces使用Javascript打开一个p:对话框,primefaces,Primefaces,我试图在加载页面时使用JavaScript打开primefaces对话框组件,但无法打开它。当页面加载时,我的“HERE!”警报将触发,但必须使用客户端的widgetvar属性找不到该组件。有人知道JavaScript中的正确引用吗 代码: jQuery(文档).ready(函数(){ 警惕(“这里!”); scrapimagesdlg.show(); }); 告诉PrimeFaces在页面加载时自动打开对话框。我主要遇到的问题是脚本块在头部而不是正文中,因此脚本在对话框创建之前就已经运

我试图在加载页面时使用JavaScript打开primefaces对话框组件,但无法打开它。当页面加载时,我的“HERE!”警报将触发,但必须使用客户端的widgetvar属性找不到该组件。有人知道JavaScript中的正确引用吗

代码:


jQuery(文档).ready(函数(){
警惕(“这里!”);
scrapimagesdlg.show();
}); 


告诉PrimeFaces在页面加载时自动打开对话框。

我主要遇到的问题是脚本块在头部而不是正文中,因此脚本在对话框创建之前就已经运行了。
<ui:composition template="#{layoutBean.registeredTemplate}">
    <ui:define name="head">
        <script type="text/javascript">
            jQuery(document).ready(function(){
                alert("HERE!");
                scrapeImagesDlg.show();
            }); 
        </script>
    </ui:define>

    <ui:define name="content">
        <p:dialog header="#{bundle['bookmarklet.dialog.HEADER']}" 
              widgetVar="scrapeImagesDlg" 
              modal="true" 
              styleClass="dialog dialog2" 
              draggable="false" 
              resizable="false"
              showEffect="fade" 
              hideEffect="fade" 
              closeListener="#{bookmarklet.close}"
            onCloseUpdate="imageGrid">

        <div class="dialog dialog2">
            <div class="dialog-top-reg"></div>

            <div class="dialog-middle-reg">
                <div class="close-button"><h:form>
                    <p:commandButton onclick="scrapeImagesDlg.hide()"/>
                </h:form></div>

                <h:form id="scrapeFrm">
                 <p:commandButton onclick="scapeImages()" value="scrape images"/>

                 <h:inputHidden id="scrapeURL" value="http://www.freefoto.com/preview/04-01-70?ffid=04-01-70"/>

                 <p:remoteCommand name="scapeImages" 
                    process="@this,scrapeURL"
                    actionListener="#{bookmarklet.loadImages}"
                    update="imageGrid"/>

                 <p:outputPanel id="imageGrid">
                    <p:dataGrid var="img" 
                        value="#{bookmarkletBean.imageURLs}" 
                        rendered="#{bookmarkletBean.shouldRender}"
                        columns="1"  
                        rows="1"
                        paginator="true"
                        effect="true" 
                        paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} " 
                        paginatorPosition="bottom"> 

                        <p:column>  
                                <h:panelGrid columns="1" style="width:100%">
                                        <p:graphicImage value="#{img}" width="100" height="100"/>   
                            </h:panelGrid>  
                        </p:column>  
                    </p:dataGrid>
                 </p:outputPanel>
                </h:form>
            </div>
            <div class="dialog-bottom-reg"></div>
        </div> 
        </p:dialog> 
    </ui:define>
</ui:composition>
<p:dialog visible="true" ...>