0

The following code implements a datatable inside a layout, in the datatable I added a menu Button whose menu Item updates the content of a dialog "outside the table" upon clicking it. I get this error upon running the cde at the browser:

JBWEB000065: HTTP Status 500 - Cannot find component with identifier ":choice" referenced from "form:accounts:0:j_idt11".

Here is the code:

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui">
<h:head>
    <link type="text/css" rel="stylesheet"
        href="#{request.contextPath}/style.css" />
</h:head>
<h:body>
    <h:form id="form">
        <p:dialog header="You selected" widgetVar="dlg" id="choice" resizable="false" modal="true">
                    This item.
                </p:dialog>

        <p:layout style="min-width:400px;min-height:200px;" id="layout">
            <p:layoutUnit position="center">
                <p:dataTable id="accounts" var="account" value="pop" rowKey="1">

                    <p:column headerText="ID"></p:column>

                    <p:column headerText="Option">

                        <p:growl id="messages" />
                        <p:menuButton value="">
                            <p:menuitem value="1" update="choice" oncomplete="dlg.show()" />
                            <p:menuitem value="2" update="choice" oncomplete="dlg.show()" />
                            <p:menuitem value="3" update="choice" oncomplete="dlg.show()" />
                        </p:menuButton>
                    </p:column>
                </p:dataTable>
            </p:layoutUnit>
        </p:layout>


    </h:form>
</h:body>
</html>

Update: When I add the dialog inside the databale it is seen by the menu button, but it either doesn't display properly, or opens and can't be closed.

Ahmed Waheed
  • 1,281
  • 5
  • 21
  • 39

1 Answers1

1

In your case, <h:form> will prepend its id to its components. To get rid of the error change your <p:menuitem> (all three) from

<p:menuitem value="1" update="choice" oncomplete="dlg.show()" />

to

<p:menuitem value="1" update=":form:choice" oncomplete="dlg.show()" />

Useful links

How can I know the id of a JSF component so I can use in Javascript

How to find out client ID of component for ajax update/render? Cannot find component with expression "foo" referenced from "bar"

Get id of parent naming container in template for in render / update attribute

Community
  • 1
  • 1
Andy
  • 5,900
  • 2
  • 20
  • 29