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

slider only writes integer even when binding curpos with a double attribute

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 7.0.4
    • 7.0.2
    • Components
    • Security Level: Jimmy
    • None

      Steps to Reproduce

      1. run the zul
        	<div apply="org.zkoss.bind.BindComposer"
        		viewModel="@id('vm')@init('support.component.SliderDoubleVM')">
        		<slider mode="decimal" maxpos="5.0" step="0.5" curpos="@bind(vm.potentialRisk)" />
        		<label value="@load(vm.potentialRisk)"></label>
        	</div>
        
      2. drag slider to decimal value like 3.5, 4.5

      Actual Result

      The output value is always integer.

      Actual Result

      The output value is double.

      Workaround

      Bind with curposInDouble

      <slider mode="decimal" maxpos="5.0" step="0.5" curposInDouble="@save(vm.potentialRisk)" curpos="@load(vm.potentialRisk)" />
      
      <?xml version="1.0" encoding="UTF-8"?>
      <language-addon>
      	<!-- The name of this addon. It must be unique -->
      	<addon-name>zkbind</addon-name>
      	<!-- Specifies what other addon this depends
      	-->
      	<depends>zul</depends>
      
      	<!-- Which language this addon will be added to -->
      	<language-name>xul/html</language-name>
      	<component>
      		<component-name>slider</component-name>
      		<extends>slider</extends>
      		<annotation>
      			<annotation-name>ZKBIND</annotation-name>
      			<property-name>curposInDouble</property-name>
      			<attribute>
      				<attribute-name>ACCESS</attribute-name>
      				<attribute-value>save</attribute-value>
      			</attribute>
      			<attribute>
      				<attribute-name>SAVE_EVENT</attribute-name>
      				<attribute-value>onScroll</attribute-value>
      			</attribute>
      		</annotation>
      	</component>
      </language-addon>
      

      Debug Information

      getCurpos() returns int, so binder always sets integer value to ViewModel. Maybe provide another getCurpos() that returns double, but I'm don't know how EL can tell which method to call.

            jumperchen jumperchen
            hawk hawk
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: