1

好吧,这个问题把我逼疯了......

我有这个 xhtml 页面,有 2 个对话框......两个对话框里面都有一个表单来向服务器发送提交,它们工作正常,但是当它们从 commandLink 表单调用和更新时,对话框表单中的 actionListener 只是没有不工作,有什么想法吗?

这是我调用对话框的菜单

<ui:define name="left">
    <h:form id="menuForm">
        <div class="sidebar-nav">
            <div class="well" style="width:150px; padding: 8px 0;">
                <ul class="nav nav-list"> 
                    <li class="text-center">Options</li>        
                    <li><p:commandLink id="createLink" update=":LocationCreateForm" actionListener="#{locationController.prepareCreate}" oncomplete="LocationCreateDialog.show()"><span class="glyphicon glyphicon-user"></span> Create New</p:commandLink> </li>
                    <li><p:commandLink id="editLink" update=":LocationEditForm" oncomplete="LocationEditDialog.show()"><span class="glyphicon glyphicon-edit"></span> Update</p:commandLink> </li>
                    <li><p:commandLink id="deleteLink" actionListener="#{locationController.delete}"><span class="glyphicon glyphicon-ban-circle"></span> Delete</p:commandLink> </li>
                </ul>
            </div>
        </div>
    </h:form>
</ui:define>

如果我从 commandLink 中删除更新,它们可以工作,但是对于编辑对话框,我无法获取要编辑的信息。

对话框和列表在哪里:

<ui:define name="content">
    <h1>Locations</h1>
    <!-- Location List -->
    <h:form id="LocationListForm">

        <p:dataTable id="datalist" value="#{locationController.items}" var="item"
                     selectionMode="single" selection="#{locationController.selected}"
                     rowKey="#{item.id}"

                     >

            <p:column sortBy="#{item.id}" filterBy="#{item.id}">
                <f:facet name="header">
                    <h:outputText value="#{myBundle.ListLocationTitle_id}"/>
                </f:facet>
                <h:outputText value="#{item.id}"/>
            </p:column>
            <p:column sortBy="#{item.name}" filterBy="#{item.name}">
                <f:facet name="header">
                    <h:outputText value="#{myBundle.ListLocationTitle_name}"/>
                </f:facet>
                <h:outputText value="#{item.name}"/>
            </p:column>
            <p:column sortBy="#{item.openingHourMonday}" filterBy="#{item.openingHourMonday}">
                <f:facet name="header">
                    <h:outputText value="#{myBundle.ListLocationTitle_openingHourMonday}"/>
                </f:facet>
                <h:outputText value="#{item.openingHourMonday}">
                    <f:convertDateTime pattern="HH:mm:ss" />
                </h:outputText>
            </p:column>
            <p:column sortBy="#{item.openingHourTuesday}" filterBy="#{item.openingHourTuesday}">
                <f:facet name="header">
                    <h:outputText value="#{myBundle.ListLocationTitle_openingHourTuesday}"/>
                </f:facet>
                <h:outputText value="#{item.openingHourTuesday}">
                    <f:convertDateTime pattern="HH:mm:ss" />
                </h:outputText>
            </p:column>
            <p:column sortBy="#{item.openingHourWednesday}" filterBy="#{item.openingHourWednesday}">
                <f:facet name="header">
                    <h:outputText value="#{myBundle.ListLocationTitle_openingHourWednesday}"/>
                </f:facet>
                <h:outputText value="#{item.openingHourWednesday}">
                    <f:convertDateTime pattern="HH:mm:ss" />
                </h:outputText>
            </p:column>
            <p:column sortBy="#{item.openingHourThrusday}" filterBy="#{item.openingHourThrusday}">
                <f:facet name="header">
                    <h:outputText value="#{myBundle.ListLocationTitle_openingHourThrusday}"/>
                </f:facet>
                <h:outputText value="#{item.openingHourThrusday}">
                    <f:convertDateTime pattern="HH:mm:ss" />
                </h:outputText>
            </p:column>
            <p:column sortBy="#{item.openingHourFriday}" filterBy="#{item.openingHourFriday}">
                <f:facet name="header">
                    <h:outputText value="#{myBundle.ListLocationTitle_openingHourFriday}"/>
                </f:facet>
                <h:outputText value="#{item.openingHourFriday}">
                    <f:convertDateTime pattern="HH:mm:ss" />
                </h:outputText>
            </p:column>
            <p:column sortBy="#{item.openingHourSaturday}" filterBy="#{item.openingHourSaturday}">
                <f:facet name="header">
                    <h:outputText value="#{myBundle.ListLocationTitle_openingHourSaturday}"/>
                </f:facet>
                <h:outputText value="#{item.openingHourSaturday}">
                    <f:convertDateTime pattern="HH:mm:ss" />
                </h:outputText>
            </p:column>
            <p:column sortBy="#{item.openingHourSunday}" filterBy="#{item.openingHourSunday}">
                <f:facet name="header">
                    <h:outputText value="#{myBundle.ListLocationTitle_openingHourSunday}"/>
                </f:facet>
                <h:outputText value="#{item.openingHourSunday}">
                    <f:convertDateTime pattern="HH:mm:ss" />
                </h:outputText>
            </p:column>
        </p:dataTable>
    </h:form>
    <!-- Location Create Dialog -->
    <p:dialog id="LocationCreateDlg" widgetVar="LocationCreateDialog" modal="true" resizable="false" appendToBody="true" header="#{myBundle.CreateLocationTitle}">

        <h:form id="LocationCreateForm">

            <h:panelGroup id="display">
                <p:panelGrid columns="2" >

                    <p:outputLabel value="#{myBundle.CreateLocationLabel_name}" for="name" />
                    <p:inputText id="name" value="#{locationController.selected.name}" title="#{myBundle.CreateLocationTitle_name}" required="true" requiredMessage="#{myBundle.CreateLocationRequiredMessage_name}"/>

                    <p:outputLabel value="#{myBundle.CreateLocationLabel_openingHourMonday}" for="openingHourMonday" />
                    <p:calendar id="openingHourMonday" pattern="HH:mm:ss" value="#{locationController.selected.openingHourMonday}" title="#{myBundle.EditLocationTitle_openingHourMonday}" required="true" requiredMessage="#{myBundle.EditLocationRequiredMessage_openingHourMonday}" showOn="button"/>

                    <p:outputLabel value="#{myBundle.CreateLocationLabel_openingHourTuesday}" for="openingHourTuesday" />
                    <p:calendar id="openingHourTuesday" pattern="HH:mm:ss" value="#{locationController.selected.openingHourTuesday}" title="#{myBundle.EditLocationTitle_openingHourTuesday}" required="true" requiredMessage="#{myBundle.EditLocationRequiredMessage_openingHourTuesday}" showOn="button"/>

                    <p:outputLabel value="#{myBundle.CreateLocationLabel_openingHourWednesday}" for="openingHourWednesday" />
                    <p:calendar id="openingHourWednesday" pattern="HH:mm:ss" value="#{locationController.selected.openingHourWednesday}" title="#{myBundle.EditLocationTitle_openingHourWednesday}" required="true" requiredMessage="#{myBundle.EditLocationRequiredMessage_openingHourWednesday}" showOn="button"/>

                    <p:outputLabel value="#{myBundle.CreateLocationLabel_openingHourThrusday}" for="openingHourThrusday" />
                    <p:calendar id="openingHourThrusday" pattern="HH:mm:ss" value="#{locationController.selected.openingHourThrusday}" title="#{myBundle.EditLocationTitle_openingHourThrusday}" required="true" requiredMessage="#{myBundle.EditLocationRequiredMessage_openingHourThrusday}" showOn="button"/>

                    <p:outputLabel value="#{myBundle.CreateLocationLabel_openingHourFriday}" for="openingHourFriday" />
                    <p:calendar id="openingHourFriday" pattern="HH:mm:ss" value="#{locationController.selected.openingHourFriday}" title="#{myBundle.EditLocationTitle_openingHourFriday}" required="true" requiredMessage="#{myBundle.EditLocationRequiredMessage_openingHourFriday}" showOn="button"/>

                    <p:outputLabel value="#{myBundle.CreateLocationLabel_openingHourSaturday}" for="openingHourSaturday" />
                    <p:calendar id="openingHourSaturday" pattern="HH:mm:ss" value="#{locationController.selected.openingHourSaturday}" title="#{myBundle.EditLocationTitle_openingHourSaturday}" required="true" requiredMessage="#{myBundle.EditLocationRequiredMessage_openingHourSaturday}" showOn="button"/>

                    <p:outputLabel value="#{myBundle.CreateLocationLabel_openingHourSunday}" for="openingHourSunday" />
                    <p:calendar id="openingHourSunday" pattern="HH:mm:ss" value="#{locationController.selected.openingHourSunday}" title="#{myBundle.EditLocationTitle_openingHourSunday}" required="true" requiredMessage="#{myBundle.EditLocationRequiredMessage_openingHourSunday}" showOn="button"/>
                </p:panelGrid>
                <p:commandButton actionListener="#{locationController.saveNew}" value="#{myBundle.Save}" update="display,:LocationListForm:datalist,:growl" oncomplete="handleSubmit(xhr,status,args,LocationCreateDialog);"/>
                <p:commandButton value="#{myBundle.Cancel}" onclick="LocationCreateDialog.hide();"/>
            </h:panelGroup>

        </h:form>

    </p:dialog>

    <!-- Location Update Dialog -->
    <p:dialog id="LocationEditDlg" widgetVar="LocationEditDialog" modal="true" resizable="false" appendToBody="true" header="#{myBundle.EditLocationTitle}">

        <h:form id="LocationEditForm">

            <h:panelGroup id="display">
                <p:panelGrid  columns="2" rendered="#{locationController.selected != null}">

                    <h:outputLabel value="#{myBundle.EditLocationLabel_id}" for="id" />
                    <h:outputText id="id" value="#{locationController.selected.id}" />

                    <p:outputLabel value="#{myBundle.EditLocationLabel_name}" for="name" />
                    <p:inputText id="name" value="#{locationController.selected.name}" title="#{myBundle.EditLocationTitle_name}" required="true" requiredMessage="#{myBundle.EditLocationRequiredMessage_name}"/>

                    <p:outputLabel value="#{myBundle.EditLocationLabel_openingHourMonday}" for="openingHourMonday" />
                    <p:calendar id="openingHourMonday" pattern="HH:mm:ss" value="#{locationController.selected.openingHourMonday}" title="#{myBundle.EditLocationTitle_openingHourMonday}" required="true" requiredMessage="#{myBundle.EditLocationRequiredMessage_openingHourMonday}" showOn="button"/>

                    <p:outputLabel value="#{myBundle.EditLocationLabel_openingHourTuesday}" for="openingHourTuesday" />
                    <p:calendar id="openingHourTuesday" pattern="HH:mm:ss" value="#{locationController.selected.openingHourTuesday}" title="#{myBundle.EditLocationTitle_openingHourTuesday}" required="true" requiredMessage="#{myBundle.EditLocationRequiredMessage_openingHourTuesday}" showOn="button"/>

                    <p:outputLabel value="#{myBundle.EditLocationLabel_openingHourWednesday}" for="openingHourWednesday" />
                    <p:calendar id="openingHourWednesday" pattern="HH:mm:ss" value="#{locationController.selected.openingHourWednesday}" title="#{myBundle.EditLocationTitle_openingHourWednesday}" required="true" requiredMessage="#{myBundle.EditLocationRequiredMessage_openingHourWednesday}" showOn="button"/>

                    <p:outputLabel value="#{myBundle.EditLocationLabel_openingHourThrusday}" for="openingHourThrusday" />
                    <p:calendar id="openingHourThrusday" pattern="HH:mm:ss" value="#{locationController.selected.openingHourThrusday}" title="#{myBundle.EditLocationTitle_openingHourThrusday}" required="true" requiredMessage="#{myBundle.EditLocationRequiredMessage_openingHourThrusday}" showOn="button"/>

                    <p:outputLabel value="#{myBundle.EditLocationLabel_openingHourFriday}" for="openingHourFriday" />
                    <p:calendar id="openingHourFriday" pattern="HH:mm:ss" value="#{locationController.selected.openingHourFriday}" title="#{myBundle.EditLocationTitle_openingHourFriday}" required="true" requiredMessage="#{myBundle.EditLocationRequiredMessage_openingHourFriday}" showOn="button"/>

                    <p:outputLabel value="#{myBundle.EditLocationLabel_openingHourSaturday}" for="openingHourSaturday" />
                    <p:calendar id="openingHourSaturday" pattern="HH:mm:ss" value="#{locationController.selected.openingHourSaturday}" title="#{myBundle.EditLocationTitle_openingHourSaturday}" required="true" requiredMessage="#{myBundle.EditLocationRequiredMessage_openingHourSaturday}" showOn="button"/>

                    <p:outputLabel value="#{myBundle.EditLocationLabel_openingHourSunday}" for="openingHourSunday" />
                    <p:calendar id="openingHourSunday" pattern="HH:mm:ss" value="#{locationController.selected.openingHourSunday}" title="#{myBundle.EditLocationTitle_openingHourSunday}" required="true" requiredMessage="#{myBundle.EditLocationRequiredMessage_openingHourSunday}" showOn="button"/>
                </p:panelGrid>
                <p:commandButton actionListener="#{locationController.save}" value="#{myBundle.Save}" update="display,:LocationListForm:datalist,:growl" oncomplete="handleSubmit(xhr,status,args,LocationEditDialog);"/>
                <p:commandButton value="#{myBundle.Cancel}" onclick="LocationEditDialog.hide();"/>
            </h:panelGroup>

        </h:form>

    </p:dialog>

</ui:define>
4

2 回答 2

8

process = "@this"p:commandButtonappendTo="@(body)"中使用p:dialog

于 2013-10-17T11:31:23.400 回答
0

已解决的问题,更新到 primefaces 4.0 RC1,更改appendToBody="true"appendTo="@(body)"

于 2013-10-01T15:52:37.550 回答