0

I'm using ajax in spinner to call some action in backing bean.

this is my code:

<b:panel>
    <p:dataTable id="orderDataTable" var="order" value="#{orderViewBean.orders}"
                 widgetVar="ordersDataTable" tableStyle="table-layout: auto;">
        <p:column headerText="Created" filterBy="#{order.creationDate}" filterStyle="display: none"
                  filterMatchMode="contains">
            <h:outputText value="#{order.creationDate}"/>
        </p:column>
        <p:column headerText="Created By" filterBy="#{order.createdBy}" filterStyle="display: none"
                  filterMatchMode="contains">
            <h:outputText value="#{order.createdBy}"/>
        </p:column>
    </p:dataTable>

    <b:panelGrid colSpans="4,4,4">
        <b:commandButton action="#{orderViewBean.previousPage}" value="Previous"
                         look="primary" process="@this:uploadOrderDataPanel" styleClass="pull-left"
                         disabled="#{!orderViewBean.page.hasPrevious()}" type="submit">
            <p:ajax immediate="true" update=":companyOrdersForm"/>
        </b:commandButton>
        <b:row>
            <div class="text-center">
                <h:outputLabel value="Page"/>
                <p:spinner value="#{orderViewBean.currentPage}" size="3"
                           min="#{orderViewBean.page.totalPages > 0 ? 1 : 0}"
                           max="#{orderViewBean.page.totalPages}">
                    <p:ajax listener="#{orderViewBean.changePageAjax}"
                            update="@form" process="@this" immediate="true"/>
                </p:spinner>
                <h:outputLabel value="Of"/>
                <h:outputText value="#{orderViewBean.page.totalPages}"/>
            </div>
        </b:row>
        <b:commandButton action="#{orderViewBean.nextPage}" value="Next"
                         look="primary" process="@this:uploadOrderDataPanel" styleClass="pull-right"
                         disabled="#{!orderViewBean.page.hasNext()}" type="submit">
            <p:ajax immediate="true" update=":companyOrdersForm"/>
        </b:commandButton>
    </b:panelGrid>
</b:panel>

When I put some number into spinner and hit enter, then changePageAjax is invoked (this is ok) and also orderViewBean.previousPage (this is not ok). Can I avoid invoking other actions?

Cœur
  • 37,241
  • 25
  • 195
  • 267
bilak
  • 4,526
  • 3
  • 35
  • 75
  • what are the b: tags? Also PrimeFaces? Or custom/composite components? – Kukeltje May 15 '15 at 10:31
  • Hint: PrimeFaces has a Bootstrap theme. – BalusC May 15 '15 at 11:39
  • @BalusC thanks, I know about that theme, I'm currenty using it, but some components are better in bootsfaces. I tried to replace bootsfaces buttons with primefaces, but I have still same issue :( – bilak May 15 '15 at 12:12

1 Answers1

0

Add a partialSubmit="true" attribute on the relevant ajax tags.. From the PF documentation:

PartialSubmit reduces network traffic by only adding the partially processed components to the ajax request post. For big pages with many input components, partialSubmit is extremely useful as it leads to more lightweight requests. Compare the Post Data displayed by the logger for the difference.

See also:

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
  • Then explain more clearly what your issue is, with screenshots of network traffic etc.... Ahhhh wait... you hit ENTER.... welll... Then the default action is executed, which normallly is the first button... See http://stackoverflow.com/questions/5485851/default-action-to-execute-when-pressing-enter-in-a-form – Kukeltje May 15 '15 at 12:10
  • Ok so basically, I'm using spinner for my custom paginator. I'd like to be able to write custom page number to this spinner, hit enter and then invoke action which will return requested page number. – bilak May 18 '15 at 12:40