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

Form Binding doesn't update the bean field when a binding bean changed

    Details

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

      Description

      http://screencast.com/t/Qwr4Jd93WB

      <zk>
      	<zscript><![CDATA[
      		class Item {
      			private String name;
      			
      			public Item(String name) {
      				this.name = name;
      			}
      			
      			public String getName() {
      				return name;
      			}
      		}
      		
      		class Product {
      			private Item item;
      			
      			public Product(Item item) {
      				this.item = item;
      			}
      			
      			public Item getItem() {
      				return item;
      			}
      			
      			public void setItem(Item item) {
      				this.item = item;
      			}
      		}
      		
      		class MyVM {
      			private List list;
      			private Product product;
      			
      			public MyVM() {
      				list = new ArrayList();
      				list.add(new Item("Item 1"));
      				list.add(new Item("Item 2"));
      				list.add(new Item("Item 3"));
      			}
      			
      			public List getList() {
      				return list;
      			}
      			
      			public Product getProduct() {
      				return product;
      			}
      			
      			public void setProduct(Product product) {
      				this.product = product;
      			}
      			
      		}
      	]]></zscript>
      	
      	
      	<window apply="org.zkoss.bind.BindComposer"
      		viewModel="@id('vm') @init('MyVM')">
      		<div form="@id('fx')@load(vm.product)">
      			<vlayout>
      				<div>
      					fx.item: <label value="@load(fx.item)"/>
      				</div>
      				<div>
      					fx.item.name: <label value="@load(fx.item.name)"/>
      				</div>
      			</vlayout>
      			<combobox model="@load(vm.list)"
      				selectedItem="@bind(fx.item)">
      				<template name="model" var="item">
      					<comboitem label="@load(item.name)"/>
      				</template>
      			</combobox>
      		</div>
      	</window>
      </zk>
      

        Issue Links

          Activity

          Hide
          dennis dennis added a comment -

          current form binding implementation use property-base solution.
          Which means.
          1.the binding is more like fx['item'] and fx['item.name'],so they are not related.
          When fx['item'] changes, fx['item.name'] doesn't know it has to be reload.

          2. Even we can fix issue 1 by a 'prefix' assumption, but it is still not work, because in the from, the value is loaded when it's initialization.
          which means, fx['item.name'] is loaded when form initial, and no matter fx['item'] changed, the value is still not related to fx['item.name'].

          Show
          dennis dennis added a comment - current form binding implementation use property-base solution. Which means. 1.the binding is more like fx ['item'] and fx ['item.name'] ,so they are not related. When fx ['item'] changes, fx ['item.name'] doesn't know it has to be reload. 2. Even we can fix issue 1 by a 'prefix' assumption, but it is still not work, because in the from, the value is loaded when it's initialization. which means, fx ['item.name'] is loaded when form initial, and no matter fx ['item'] changed, the value is still not related to fx ['item.name'] .
          Hide
          jimmyshiau jimmyshiau added a comment -

          workaround

          <div>
          	fx.item: <label value="@load(fx.item)"/>
          </div>
          <div>
          	fx.item.name: <label value="@load(fx.item.name)"/>
          </div>
          <div>
          	refitem.name: <label item="@ref(fx.item)" value="@load(item.name)"/>
          </div>
          
          <combobox model="@load(vm.list)"
          	selectedItem="@bind(fx.item)">
          	<template name="model" var="item">
          		<comboitem label="@load(item.name)"/>
          	</template>
          </combobox>
          		
          
          Show
          jimmyshiau jimmyshiau added a comment - workaround <div> fx.item: <label value= "@load(fx.item)" /> </div> <div> fx.item.name: <label value= "@load(fx.item.name)" /> </div> <div> refitem.name: <label item= "@ref(fx.item)" value= "@load(item.name)" /> </div> <combobox model= "@load(vm.list)" selectedItem= "@bind(fx.item)" > <template name= "model" var= "item" > <comboitem label= "@load(item.name)" /> </template> </combobox>
          Hide
          jumperchen jumperchen added a comment -

          Bug fixed since 12/30/2014

          Show
          jumperchen jumperchen added a comment - Bug fixed since 12/30/2014

            People

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

              Dates

              • Created:
                Updated:
                Resolved: