Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Form does not update values when an InputTransformer is set

    In the following testcase i have a selectItem with an inputtransformer (in this case it's really trivial). Now when changing the value of this selectitem no change handlers are fired. Neither is form.getValues() updated with the new value of the selectitem.

    This seemed to happen only when I defined the datasourcefields myself, and not when I loaded them from an xml datasource.

    When I remove the inputtransformer, the events get fired fine and getValues() is updated properly.

    This was tested on SmartClient Version: SC_SNAPSHOT-2010-11-15/PowerEdition Deployment (built 2010-11-15) with GWT 2.0.4 on firefox 3.6.12

    Code:
    package test.client;
    
    import java.util.Map;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.widgets.IButton;
    import com.smartgwt.client.widgets.events.ClickEvent;
    import com.smartgwt.client.widgets.events.ClickHandler;
    import com.smartgwt.client.widgets.form.DynamicForm;
    import com.smartgwt.client.widgets.form.FormItemInputTransformer;
    import com.smartgwt.client.widgets.form.fields.FormItem;
    import com.smartgwt.client.widgets.form.fields.SelectItem;
    import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
    import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
    import com.smartgwt.client.widgets.layout.HLayout;
    
    public class InputValueTransformerTest implements EntryPoint {
    	
    	public void onModuleLoad() {
    		final DynamicForm form = new DynamicForm();
    		form.setDataSource(MyTestDatasource.getInstance());
    		
    		SelectItem firstSelectItem = new SelectItem("cntn_fk_customer", "Customer");
    		firstSelectItem.setOptionDataSource(DataSource.get("Customer"));
    		firstSelectItem.setInputTransformer(new FormItemInputTransformer() {
    			@Override
    			public Object transformInput(DynamicForm form, FormItem item, Object value, Object oldValue) {
    				return value;
    			}
    		});
    		firstSelectItem.setDisplayField("cstm_name");
    		firstSelectItem.addChangedHandler(new ChangedHandler() {
    			@Override
    			public void onChanged(ChangedEvent event) {
    				System.err.println("firstSelectItem changed");
    			}
    		});
    		form.setFields(firstSelectItem);
    		
    		IButton button = new IButton();
    		button.addClickHandler(new ClickHandler() {
    			
    			@Override
    			public void onClick(ClickEvent event) {
    				System.err.println("onClick");
    				for(Map.Entry<String, Object> entry: ((Map<String,Object>)form.getValues()).entrySet()) {
    					System.err.println(entry.getKey() + " => " + entry.getValue());
    				}
    				
    			}
    		});
    		
    		HLayout layout = new HLayout();
    		layout.addMember(form);
    		layout.addMember(button);
    		layout.draw();
    	}	
    	
    
    }

    Code:
    package test.client;
    
    
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.data.Record;
    import com.smartgwt.client.data.fields.DataSourceIntegerField;
    
    public class MyTestDatasource extends DataSource {  
    	
    	private static MyTestDatasource instance = null;
    	
    	public static MyTestDatasource getInstance() {
            if (instance == null) {
                instance = new MyTestDatasource("testDataSource");
            }
            return instance;
        }
    
        public MyTestDatasource(String id) {
            setID(id);
            setClientOnly(true);  
            DataSourceIntegerField dynamicField = new DataSourceIntegerField("cntn_fk_customer", "Customer", 10, false);
    		setFields(dynamicField);
    		Record record = new Record();
    		record.setAttribute("cntn_fk_customer", 1);
    		addData(record);
        }
    }
    Code:
    <DataSource 
    	serverType="sql"
    	dbName="Mysql"
    	tableName="Customer"
    	ID="Customer"
    >
    	<fields>
    		<field primaryKey="true" type="sequence" name="cstm_pk" hidden="true"></field>
    		<field type="text" length="45" name="cstm_name" title="" required="true" export="true"></field>
    	</fields>
    </DataSource>
    Last edited by RubenS; 17 Nov 2010, 02:11.

    #2
    This looks to be a temporary issue which has been resolved since the build you were using. Can you try the latest night, "SC_SNAPSHOT-2010-11-17/..." and let us know if you still see the problem

    Thanks

    Comment


      #3
      I still have it in the latest nightly. It also occurs on the nightly of 22 september (this is the one we currently use)

      Comment


        #4
        Ok we're seeing it - we'll let you know when we have a fix

        Comment


          #5
          This should be fixed in the next nightly. Please try it out and report your findings.

          Thanks,
          Sanjiv

          Comment

          Working...
          X