1

I am trying to use Ajax with a command link to update a dialog. Te form doesn't have any id, I am not able to run this page also, it says component with "dialog" not found/doesn't exist

<h:form>
    <p:tabView id="tabView">
        <p:tab id="tab1" title="Tab 1">
            <h:panelGrid columns="1" cellpadding="10">
                <h:dataTable value="#{testBean.dataList}" var="data">
                    <h:column>
                        <h:outputText value="#{data}" />
                    </h:column>
                    <h:column>
                        <p:commandLink action="#{testBean.loadCommentHistory(data)}"
                            update="dialog" oncomplete="dlg.show()">
                            <h:graphicImage url="resources/theme1/images/comments.gif"
                                styleClass="basicImageStyle" />
                        </p:commandLink>
                    </h:column>
                </h:dataTable>
                <p:dialog id="dialog" header="Dynamic Dialog" widgetVar="dlg">
                    <h:outputText value="#{testBean.commentHistory}" />
                </p:dialog>
            </h:panelGrid>
        </p:tab>
    </p:tabView>
</h:form>
phant0m
  • 16,595
  • 5
  • 50
  • 82
aryanRaj_kary
  • 503
  • 2
  • 7
  • 28

1 Answers1

1

The p:dataTable itself is a container. The p:commandLink is searching within the p:dataTable for an element with an id "dialog".

Solution: add an id to the form and refer to the dialog as ":formid:dialog".

Edit:

The p:tabView or the p:tab is also a container so check the id of the dialog in your browser and use that one. ;-) It should be noted to avoid id's as jdt_id4.

siebz0r
  • 18,867
  • 14
  • 64
  • 107
  • this is id I can in the browser page source - j_idt7:tabView:dialog – aryanRaj_kary Dec 08 '12 at 17:31
  • Give your form an id (`form id="formId"`) and use `update=":formId:tabView:dialog"`. The first ":" refers to the root element of the page. – siebz0r Dec 08 '12 at 18:01
  • If the answer I gave works for you, please mark it as accepted ;-) The root element is ``. For more about referencing elements, see [this question](http://stackoverflow.com/questions/8634156/). – siebz0r Dec 08 '12 at 18:40
  • The dialog is displayed in IE and firefox, but not in Google Chrome v23 – aryanRaj_kary Dec 12 '12 at 11:15
  • @aryanRaj_kary Sounds like a different issue. Please open another question for this. Don't ask follow-up questions in the comments, see http://meta.stackexchange.com/questions/19457/where-should-i-post-follow-up-questions ;-) – siebz0r Dec 12 '12 at 11:40
  • ok, opened a new question on this issue - http://stackoverflow.com/questions/13839894/prime-faces-dialog-not-working-in-chrome-browser – aryanRaj_kary Dec 12 '12 at 12:34