Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-2078

FormBinding with collections does not cache the changes

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: 7.0.0, 6.5.4
    • Fix Version/s: 8.0.0
    • Component/s: Databind 2
    • Security Level: Jimmy
    • Labels:

      Description

      the attached example shows a model object "Item" with a collection member (List<Tag>)
      when using the "Item"-object with form binding, the changes to items in the collection are written directly to the "Tag"-objects in the original collection (same with adding/removing tags)
      this makes the form binding pointless in such situations using the default implementation.

        Issue Links

          Activity

          Show
          cor3000 cor3000 added a comment - also related: http://forum.zkoss.org/question/77100/form-binding-with-child-collections-middle-object-not-cloning-collections/
          Hide
          dennis dennis added a comment -

          The FormBinding doesn't handle collection inside currently,
          There are 3 issues need to be handle in the case.
          1.The update to tag should store in form and update later.
          2.The add new tag should store in form and create(how could I create a user's bean?) later
          3.The delete old tag should store in form and delete later.

          for 1. could consider to use nested form. such as.

          <grid form="@id('fx') @load(vm.currentItem) @save(vm.currentItem, before='save')">
          	<row>
          	Tags:
          	<cell>
          		<listbox model="@load(fx.tags)">
          			<template name="model">
          				<listitem form="@id('fx2') @load(each) @save(each, before='save')">
          					<listcell>
          						<hlayout>
          							<textbox value="@bind(fx2.value)" />
          						</hlayout>
          					</listcell>
          				</listitem>
          			</template>
          		</listbox>
          ....
          

          However, for 2,3, there are no good solution yet for just using form-binding. we need a new (not-just) form-binding.

          Show
          dennis dennis added a comment - The FormBinding doesn't handle collection inside currently, There are 3 issues need to be handle in the case. 1.The update to tag should store in form and update later. 2.The add new tag should store in form and create(how could I create a user's bean?) later 3.The delete old tag should store in form and delete later. for 1. could consider to use nested form. such as. <grid form= "@id('fx') @load(vm.currentItem) @save(vm.currentItem, before='save')" > <row> Tags: <cell> <listbox model= "@load(fx.tags)" > <template name= "model" > <listitem form= "@id('fx2') @load(each) @save(each, before='save')" > <listcell> <hlayout> <textbox value= "@bind(fx2.value)" /> </hlayout> </listcell> </listitem> </template> </listbox> .... However, for 2,3, there are no good solution yet for just using form-binding. we need a new (not-just) form-binding.
          Hide
          jumperchen jumperchen added a comment -

          Bug fixed since 12/30/2014, the form binding can now support to cache the Collection or Map type object.

          Show
          jumperchen jumperchen added a comment - Bug fixed since 12/30/2014, the form binding can now support to cache the Collection or Map type object.

            People

            • Assignee:
              jumperchen jumperchen
              Reporter:
              cor3000 cor3000
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: