DaKermit
DaKermit

Reputation: 11

<p:dataScroller> reloading automatically on entity edits

I have a p:datascroller configured to display a list of entities and lazy loading them upon clicking the more button.

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

In addition, I have a dialog that pops up when the p:commandLink oncomplete method is executed where I can update the value of the current selection and persist the changes.

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

The backing bean is configured to be @ViewScoped and everything works as defined. However, upon update the values of the p:datascroller are reset and the load method of the lazy loading model is executed and the datascroller is repopulated with new values from the database.

I have no reference to the datascroller or its containing form in the p:dialog and am wondering why the datascroller is being updated automagically? What am I missing in the equation. Have I overlooked something or something specific to the p:datascroller model that I need to consider when following this approach?

Look forward to the expertise of the community in resolving this issue. Many thanks in advance :)

Upvotes: 1

Views: 316

Answers (0)

Related Questions