从数据表中无法看到Primefaces Dialog id

时间:2013-08-01 08:56:49

标签: jsf primefaces

以下代码在布局中实现了一个数据表,在数据表中我添加了一个菜单按钮,其菜单项在单击它时更新“在表外”对话框的内容。 我在浏览器上运行cde时遇到此错误:

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

以下是代码:

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

更新:当我在数据库中添加对话框时,它会被菜单按钮看到,但它无法正常显示,或者打开并且无法关闭。

1 个答案:

答案 0 :(得分:1)

在您的情况下,<h:form>会将其ID添加到其组件中。要摆脱错误,请从

更改<p:menuitem>(全部三个)
<p:menuitem value="1" update="choice" oncomplete="dlg.show()" />

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

有用的链接

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