开发者

Primefaces open a p:dialog using Javascript

I'm trying to use JavaScript to open the primefaces dialog component when a page loads but I'm unable to get it to open. My "HERE!" alert gets fires off when the page loads but the component must not be found using the widgetvar property on the client side. Anyone know the proper reference in JavaScript?

Code:

<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" ...>

tells PrimeFaces to open the dialog automatically when page is loaded.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜