1

我将 ap:datascroller 配置为显示实体列表并在单击更多按钮时延迟加载它们。

<h:form id="investigationOperationsForm">
        <p:dataScroller
            value="#{investigationManagerBackingBean.lazyLoadedInvestigationOperations}"
            var="investigationOperation" chunkSize="9" lazy="true"
            rowIndexVar="test">
            <f:facet name="header">
                    Scroll down to load investigations
            </f:facet>


            <h:panelGrid columns="2" style="width:100%"
                columnClasses="logo,detail">

                <p:commandLink oncomplete="PF('investigationDialogW').show()"
                    update="investigationEditorForm" immediate="true">
                    <f:setPropertyActionListener value="#{investigationOperation}"
                        target="#{investigationManagerBackingBean.selection}" />
                    <p:graphicImage alt="Investigation Operation"
                        url="/images/common/investigation-operation.png" />
                </p:commandLink>


                <!--  h:outputText value="#{investigationOperation.name}" /-->
                <p:outputPanel id="pnl">
                    <h:panelGrid columns="2" cellpadding="5">

                        <h:outputText value="Name:" />
                        <h:outputText value="#{investigationOperation.name}"
                            style="font-weight: bold" />

                        <h:outputText value="Description:" />
                        <h:outputText value="#{investigationOperation.shortDescription}"
                            style="font-weight: bold" />

                    </h:panelGrid>
                    <p:draggable for="pnl" />
                </p:outputPanel>
            </h:panelGrid>
            <f:facet name="loader">
                <p:outputPanel
                    visible="#{investigationManagerBackingBean.lazyLoadedInvestigationOperations.rowCount gt 10}"
                    rendered="#{investigationManagerBackingBean.lazyLoadedInvestigationOperations.rowCount gt 10}">
                    <p:commandLink value="More" />
                </p:outputPanel>
            </f:facet>

        </p:dataScroller>

    </h:form>

此外,当执行该方法时,我会弹出一个对话框,p:commandLink oncomplete我可以在其中更新当前选择的值并保留更改。

<p:dialog id="investigationDialog"
        header="#{msg['inv-manager.invDialog.header.title']}"
        widgetVar="investigationDialogW" minWidth="400" minHeight="400"
        resizable="false" position="center center" modal="true">

        <p:panel id="investigationEditorPanel">
            <h:form id="investigationEditorForm">
                <h:panelGrid columns="2" cellpadding="5">

                    <h:outputLabel for="name"
                        value="#{msg['inv-manager.invDialog.nameFieldLabel']}" />
                    <p:inplace id="nameInplaceEditor" editor="true">
                        <p:inputText
                            value="#{investigationManagerBackingBean.selection.name}"
                            id="name" required="true" immediate="true"
                            label="#{msg['inv-manager.invDialog.nameFieldInputLabel']}" />
                    </p:inplace>


                    <h:outputLabel for="shortDescription"
                        value="#{msg['inv-manager.invDialog.shortDescriptionFieldLabel']}" />
                    <p:inplace id="shortDescriptionInplaceEditor" editor="true">

                        <p:inputText
                            value="#{investigationManagerBackingBean.selection.shortDescription}"
                            id="shortDescription" required="true" immediate="true"
                            label="#{msg['inv-manager.invDialog.shortDescriptionFieldInputLabel']}" />
                    </p:inplace>

                    <h:outputLabel for="description"
                        value="#{msg['inv-manager.invDialog.descriptionFieldLabel']}" />
                    <p:inputTextarea id="description" required="false"
                        label="#{msg['inv-manager.invDialog.descriptionFieldInputLabel']}"
                        immediate="true"
                        value="#{investigationManagerBackingBean.selection.description}" />


                    <p:commandButton id="okButton"
                        value="#{msg['inv-manager.invDialog.okButton']}" type="submit"
                        partialSubmit="true" process="investigationEditorForm"
                        action="#{investigationManagerBackingBean.createOrUpdate()}"
                        onclick="dlg.hide();" />

                </h:panelGrid>
            </h:form>
        </p:panel>

    </p:dialog>

支持 bean 被配置为@ViewScoped并且一切都按定义工作。但是,在更新时,值会p:datascroller被重置,延迟加载模型的加载方法会被执行,并且数据滚动器会重新填充数据库中的新值。

我在 p:dialog 中没有引用 datascroller 或其包含形式,我想知道为什么 datascroller 会自动更新?我在等式中缺少什么。在采用这种方法时,我是否忽略了某些特定于 p:datascroller 模型的东西?

期待社区的专业知识来解决这个问题。提前谢谢了 :)

4

0 回答 0