Lightweight Requests with PartialSubmit

Lightweight Requests with PartialSubmit

Core JSF Ajax implementation and PrimeFaces serializes the whole form to build the post data in ajax requests so the same data is posted just like in a non-ajax request. This has a downside in large views where you only need to process/execute a minor part of the view. Assume you have a form with 100 input fields, there is an input field with ajaxbehavior attached processing only itself(@this) and then updates another field onblur. Although only a particular input field is processed, whole form data will be posted with the unnecessary information that would be ignored during server side processing but consume resources.

Upon request of an Enterprise PrimeFaces User who have large JSF pages and trying to reduce the network load, we’ve added partialSubmit feature to PrimeFaces Ajax extensions. This attribute is available in p:ajax and ajax enabled components like buttons, links and more. When enabled and partial processing is defined, only the partially processed components are added to the post data and rest in the same form are ignored. Here is an example;

Compare the post data;





End result is same however partialSubmit is significantly more lightweight and difference becomes larger as the form grows with more components. Check out the live demo of partialSubmit and compare the post data displayed in Log components. Once our implementation is solid and stable we have plans to enable partialSubmit by default.

This is one of the 2 new ajax features of 3.3 we’ve mentioned before, stay tuned for the second one. It’s really cool!

Update: partialSubmit will be true by default if there are partially processed components defined.

  • Oleg
    14 March 2012 at 11:50

    Hello Cagatay,

    The main goal of this feature was to reduce network traffic. Right? It would be also really interesting to compare the time of request preparation (in ms) in both approaches. Can you do this? :-). Thanks.

  • Nicolas
    14 March 2012 at 12:15

    I bet this is a mobile enterprise user.

  • Aleksandar Nikolov
    14 March 2012 at 12:18

    Great! It is getting better by the day!

  • hh
    14 March 2012 at 13:13

    is it like richfaces ajax4j ajaxSingle=true ?

  • Leo
    14 March 2012 at 14:04

    This is great feature, but isn’t partialSubmit attribute more superfluous. Can this be done in the manner: If process set, then do partial submit, else submit whole form.

    • dasgin
      20 March 2012 at 22:02

      The default behaviour of JSF should not be changed. Maybe someone reads other params from request while partial processing..

  • kwintesencja
    14 March 2012 at 14:16

    as far i know ajaxSingle=true is now process=@this in richfaces 4.x

  • Philip
    14 March 2012 at 14:22

    Time spent on the client side to save time on the server side is always awesome.

  • johnypok
    14 March 2012 at 15:38

    Maybe this is not the best place to put it, but what about bypassUpdates=”true”.
    I wrote about this here:
    Are there any plans for such parameter?

  • west farmer
    14 March 2012 at 15:52

    Good feathure,

  • Danilo G. Magrini
    14 March 2012 at 16:35

    Wait … Should the first button have process=”name” for the correct test right?

  • Howard
    14 March 2012 at 17:29

    Interesting concept/feature/component. I tested the showcase sample and had a question about test results. I’ll have to create a forum topic and ask there. 🙂

  • Pelz Rutsche
    18 March 2012 at 15:33

    Are there plans for AutoComplete to implement the interface AjaxSource so it supports partialSubmit as well?

  • zy
    19 March 2012 at 09:57
  • Oleg
    21 March 2012 at 13:12

    @Pelz Rutsche. AutoComplete “query” suggestions requests are out at the moment. No support of this feature. PrimeFaces should make sure, that also internal ajax requests offer a support for this great feature.

Post a Comment