5 Replies Latest reply on Feb 24, 2011 1:16 PM by nigiyan

    How to avoid full form submittion on each ajax request?

    nigiyan

      Hi All,

      We're using richfaces 3.3.3 with Seam 2.2.0 in our web app. Mainly the forms in xhtml files are quite big and almost all elements have ajax support on "onchange" event. With firebug tool we noticed that each time almost all element of form are submitted when any ajax request is performed. Embedding one form to another does not help. Can you suggest a way to minimize submitted data?

       

      In list below you can see submitted data when ajax request is triggered from field with id 'ctySupp'.Imagine that this is quite small "document"

       

      AJAX:EVENTS_COUNT1
      AJAXREQUEST_viewRoot
      ajaxSinglettGenForm:s_ctySupp:ctySupp
      javax.faces.ViewStatej_id16
      ttGenFormttGenForm
      ttGenForm:ctnTable:0:s_cargoType:cargoTypeDry bulk pressurized
      ttGenForm:ctnTable:0:s_number:number123
      ttGenForm:ctnTable:0:s_sealNumber:sealNumber1
      ttGenForm:ctnTable:0:s_size:sizeNOT STATED
      ttGenForm:ctnTable:1:s_cargoType:cargoTypeGeneral purpose with opening(s)
      ttGenForm:ctnTable:1:s_number:number567
      ttGenForm:ctnTable:1:s_sealNumber:sealNumber1
      ttGenForm:ctnTable:1:s_size:size20'
      ttGenForm:docTable:0:s_name:name1
      ttGenForm:docTable:0:s_type:typeFI
      ttGenForm:docTable:1:s_name:name1
      ttGenForm:docTable:1:s_type:typeTransport Document
      ttGenForm:expCtyNamARMENIA
      ttGenForm:fcvrDat
      ttGenForm:fcvrNum
      ttGenForm:impCtyNamGHANA
      ttGenForm:impPrp
      ttGenForm:invPanel
      ttGenForm:logField
      ttGenForm:pdsTable:0:fDutiableVal
      ttGenForm:pdsTable:0:fhscod
      ttGenForm:pdsTable:0:finvCurAFA
      ttGenForm:pdsTable:0:fpdDpd1
      ttGenForm:pdsTable:0:fprice
      ttGenForm:pdsTable:0:fqty
      ttGenForm:pdsTable:0:funit
      ttGenForm:pdsTable:0:funitPrice
      ttGenForm:pdsTable:0:s_DHscod:DHscod1401200000
      ttGenForm:pdsTable:0:s_DHscod:j_id1240_selection
      ttGenForm:pdsTable:0:s_Dprice:Dprice1.00
      ttGenForm:pdsTable:0:s_dDutiableVal:dDutiableVal1.00
      ttGenForm:pdsTable:0:s_dinvCur:dinvCurAFA
      ttGenForm:pdsTable:0:s_dqty:dqty1.00
      ttGenForm:pdsTable:0:s_dunit:dunit2U
      ttGenForm:pdsTable:0:s_dunitPrice:dunitPrice1.00
      ttGenForm:pdsTable:0:s_pdDpd:pdDpd1
      ttGenForm:pdsTable:1:fDutiableVal0.00
      ttGenForm:pdsTable:1:fhscod
      ttGenForm:pdsTable:1:finvCurAFA
      ttGenForm:pdsTable:1:fpdDpd1
      ttGenForm:pdsTable:1:fprice
      ttGenForm:pdsTable:1:fqty
      ttGenForm:pdsTable:1:funit
      ttGenForm:pdsTable:1:funitPrice
      ttGenForm:pdsTable:1:s_DHscod:DHscod6601910000
      ttGenForm:pdsTable:1:s_DHscod:j_id1240_selection
      ttGenForm:pdsTable:1:s_Dprice:Dprice1.00
      ttGenForm:pdsTable:1:s_dDutiableVal:dDutiableVal1.00
      ttGenForm:pdsTable:1:s_dinvCur:dinvCurAFA
      ttGenForm:pdsTable:1:s_dqty:dqty1.00
      ttGenForm:pdsTable:1:s_dunit:dunitBt
      ttGenForm:pdsTable:1:s_dunitPrice:dunitPrice1.00
      ttGenForm:pdsTable:1:s_pdDpd:pdDpd1
      ttGenForm:remarks
      ttGenForm:s_DAssist:DAssist
      ttGenForm:s_DBrokerage:DBrokerage
      ttGenForm:s_DCommission:DCommission
      ttGenForm:s_DContainer:DContainer
      ttGenForm:s_DFreight:DFreight
      ttGenForm:s_DFreightNotInv:DFreightNotInv
      ttGenForm:s_DHdlNotInv:DHdlNotInv
      ttGenForm:s_DInsurance:DInsurance
      ttGenForm:s_DIntDuttax:DIntDuttax
      ttGenForm:s_DIntFreight:DIntFreight
      ttGenForm:s_DInterest:DInterest
      ttGenForm:s_DInvTotVal:DInvTotVal2.00
      ttGenForm:s_DItmTotVal:DItmTotVal2.00
      ttGenForm:s_DLuhNotInv:DLuhNotInv
      ttGenForm:s_DOther:DOther
      ttGenForm:s_DOtherDut:DOtherDut
      ttGenForm:s_DPeCharges:DPeCharges
      ttGenForm:s_DProceed:DProceed
      ttGenForm:s_DRoyLic:DRoyLic
      ttGenForm:s_DTotDutVal:DTotDutVal2.00
      ttGenForm:s_FAssist:FAssist
      ttGenForm:s_FBrokerage:FBrokerage
      ttGenForm:s_FCommission:FCommission
      ttGenForm:s_FContainer:FContainer
      ttGenForm:s_FFreightNotInv:FFreightNotInv
      ttGenForm:s_FHdlNotInv:FHdlNotInv
      ttGenForm:s_FIntDuttax:FIntDuttax
      ttGenForm:s_FIntFreight:FIntFreight
      ttGenForm:s_FInterest:FInterest
      ttGenForm:s_FInvTotVal:FInvTotVal0.00
      ttGenForm:s_FItmTotVal:FItmTotVal0.00
      ttGenForm:s_FLuhNotInv:FLuhNotInv
      ttGenForm:s_FOther:FOther
      ttGenForm:s_FOtherDut:FOtherDut
      ttGenForm:s_FPeCharges:FPeCharges
      ttGenForm:s_FProceed:FProceed
      ttGenForm:s_FRoyLic:FRoyLic
      ttGenForm:s_FTotDutVal:FTotDutVal0.00
      ttGenForm:s_appAdr:appAdrBOX 578ACCRA
      ttGenForm:s_appCity:appCity
      ttGenForm:s_appContactPerson:appContactPerson
      ttGenForm:s_appEmail:appEmail
      ttGenForm:s_appNam:appNamASANTE KONADU VIDA
      ttGenForm:s_appTel:appTel
      ttGenForm:s_appTin:appTin3170024956
      ttGenForm:s_blDate:blDateInputCurrentDate11/2010
      ttGenForm:s_blDate:blDateInputDate17/11/2010
      ttGenForm:s_blNum:blNum1
      ttGenForm:s_ctySupp:ctySuppCH
      ttGenForm:s_ctySupp:j_id794ttGenForm:s_ctySupp:j_id794
      ttGenForm:s_dInvNum:dInvNum1
      ttGenForm:s_dischargePort:dischargePortTHKRA
      ttGenForm:s_expAdr:expAdraddr
      ttGenForm:s_expCity:expCityq
      ttGenForm:s_expCty:expCtyAM
      ttGenForm:s_expNam:expNamname
      ttGenForm:s_expTin:expTin
      ttGenForm:s_expTradeLevel:expTradeLevel123
      ttGenForm:s_fFreight:fFreight
      ttGenForm:s_fInsurance:fInsurance
      ttGenForm:s_fclNum:fclNum1
      ttGenForm:s_grsWgt:grsWgt1.00
      ttGenForm:s_idfDat:idfDatInputCurrentDate11/2010
      ttGenForm:s_idfDat:idfDatInputDate16/11/2010
      ttGenForm:s_idfNum:idfNum1
      ttGenForm:s_impAdr:impAdrBOX 578ACCRA
      ttGenForm:s_impCity:impCity
      ttGenForm:s_impCty:impCtyGH
      ttGenForm:s_impNam:impNamASANTE KONADU VIDA
      ttGenForm:s_impTin:impTin3170024956
      ttGenForm:s_impTradeLevel:impTradeLevel
      ttGenForm:s_incoterm:incotermCFR
      ttGenForm:s_invCur:invCurAFA
      ttGenForm:s_invCurRat:invCurRat
      ttGenForm:s_invDat:invDatInputCurrentDate12/2010
      ttGenForm:s_invDat:invDatInputDate08/12/2010
      ttGenForm:s_lclNum:lclNum1
      ttGenForm:s_loadPort:loadPortTHKRA
      ttGenForm:s_marks:marksthe marks
      ttGenForm:s_modeOfPayment:modeOfPayment6
      ttGenForm:s_netWgt:netWgt1.00
      ttGenForm:s_pdsNbr:pdsNbr2
      ttGenForm:s_shipMod:shipMod1
      ttGenForm:s_totPck:totPck1
      ttGenForm:s_totalInvoice:totalInvoice1.00
      ttGenForm:s_transshipPort:transshipPortTHKYO
      ttGenForm:s_ucrNum:ucrNum1
      ttGenForm:s_vessel:vessel1
      ttGenForm:s_voyageNum:voyageNum1
      ttGenForm:statusLabelGenerated
      ttGenForm:tabPanelgen
        • 1. Re: How to avoid full form submittion on each ajax request?
          mopper

          Setting ajaxSingle="true" on your onchange events will cause a4j to only submit the value of the current component (the one that triggered the onchange). If you need to submit more, you can use the process="" attribute to specify the ID's of additional components that need to be included in the submit.

          • 2. Re: How to avoid full form submittion on each ajax request?
            nbelaevski

            Kim,

             

            Actually, this affects only server-side processing, but the whole form is still being submitted in both ajaxSingle/process cases.

            • 3. Re: How to avoid full form submittion on each ajax request?
              mopper

              @Nick: Ah, ok. Misunderstanding on my part, thanks for clearing that out.

               

              @Aram: Then I think the only way to reduce the amount of values submitted would be to split up your form into several forms (not embedding them).

               

              Also, if there is no need to submit all the values on the onchange event, it may still be beneficial to use ajaxSingle so that less is processed on the server-side, which may have a noticeable effect on performance.

              1 of 1 people found this helpful
              • 4. Re: How to avoid full form submittion on each ajax request?
                nigiyan

                Thanks Kim, I thought about splitting input data on separate parts like

                form id=part1

                ...

                /form

                 

                form id=part2

                ...

                /form

                 

                a:commandButtond ajaxSingle=true process=part1, part2

                 

                but this is more like workaround which makes project more and more dependent from Richfaces' implementation of ajax.

                • 5. How to avoid full form submittion on each ajax request?
                  nigiyan

                  Recently I discovered Seam Remoting as partial replacement of Richfaces' ajax in project I'm working on. But solution might require many javascript code to replace UI components (JSF) rerendering upon response arrival.

                  In general, I would recommend to everyone who is new to SEAM to get aquainted with Seam Remoting.