Go Back   SmartClient Forums > Smart GWT Technical Q&A
Wiki Register Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 9th Nov 2011, 00:41
Sytematic Sytematic is offline
Registered Developer
 
Join Date: Nov 2010
Posts: 248
Default setAllowEmptyValue(true) does not work with update operation

Hello,

In SmartClient Version: SC_SNAPSHOT-2011-11-08/PowerEdition Deployment (built 2011-11-08).


When updating an existing record in a form with a selectItem that allows an empty value:

Code:
final SelectItem teaSel = new SelectItem("Teacher_id", "Teacher");
teaSel.setOptionDataSource(DataSource.get("Teacher"));
teaSel.setValueField("Teacher_id");
teaSel.setDisplayField("surname");
teaSel.setAllowEmptyValue(true);
When i select the empty value in the selectitem, and save the form using:
Code:
form.saveData();
It should mean that Teacher_id will be persisted to NULL. Instead it does not send this field to the server at all, thus the update method leaves it untouched. So the Teacher_id value stays at its old value instead of being NULL'd.

I remember this used to work before, so is it a small regression? All my forms with this kind of behaviour throughout my app suffer from this.
Reply With Quote
  #2  
Old 9th Nov 2011, 09:59
Isomorphic Isomorphic is online now
Administrator
 
Join Date: May 2006
Posts: 37,455
Default

This could be influence by DataSource and form settings and depends on what kind of DataSource it is (REST, SGWT server, etc). Can you make this into a minimal test case? Then we can take a look.
Reply With Quote
  #3  
Old 9th Nov 2011, 10:30
Sytematic Sytematic is offline
Registered Developer
 
Join Date: Nov 2010
Posts: 248
Default

Will try.


Some details already:
1. I use smartgwt server , and the datasource is a normal SQL datasource.
2. The field is not being sent to the server, ie. it's just not present in the json object sent to the server.


Also, so far it seems that it happens with foreign keys, as this Datasource definition shows. The Teacher_id and Location_id are set using a SelectItem, and shows the problem. The SQL definition allows null for the fields Teacher_id and Location_id, obviously.

Code:
<?xml version="1.0" encoding="UTF-8"?>

<DataSource ID="LectureTemplate" serverType="sql" tableName="LectureTemplate"> 
  <fields> 
    <!-- Id, with primaryKey -->  
    <field name="LectureTemplate_id" type="sequence" primaryKey="true"/>  

...
    <field name="Course_id" type="integer" foreignKey="Course.Course_id"> 
      <validators></validators> 
    </field>  
    <field name="Teacher_id" type="integer" foreignKey="Teacher.Teacher_id"> 
      <validators></validators> 
    </field>  
    <field name="Location_id" type="integer" foreignKey="Location.Location_id"> 
      <validators></validators> 
    </field>  
  </fields>  
  <operationBindings> 
    <operationBinding operationType="update" requiresAuthentication="true" requiresRole="CAN_UPDATE_LECTURETEMPLATE"> 
    </operationBinding>  
  </operationBindings> 
</DataSource>
Reply With Quote
  #4  
Old 1st May 2012, 05:10
Sytematic Sytematic is offline
Registered Developer
 
Join Date: Nov 2010
Posts: 248
Default

Finally had time to create a stand-alone testcase (see link). It is an Eclipse project + sql file to import as tables with relevant test data. I removed the /lib/ dir et al., to reduce file size.

http://www.sytematic.nl/SGWTTestCase.zip

What to do to reproduce the problem:
0. Run the included .sql file to obtain the table structure + test data
1. Run the app
2. Set the Teacher or Location field to 'empty'
3. Click Save button
4. Observe that the database still has Location_id = 1, rather than NULL

I wonder what causes this!
Reply With Quote
  #5  
Old 4th May 2012, 13:01
Isomorphic Isomorphic is online now
Administrator
 
Join Date: May 2006
Posts: 37,455
Default

Thanks for your effort, but we don't take Eclipse projects as test cases (too many possibilities for there to be an issue in the project itself and too much time to set up). If this is a real bug, it should be trivial to modify one of the sample projects (eg builtInDS) to demonstrate it - then you can just post the changes and we can try it very easily, with no possibility of time blown troubleshooting .project files.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads
Thread Thread Starter Forum Replies Last Post
OperationID for update operation in ListGrid argopm Technical Q&A 9 12th May 2011 18:00
How to avoid dragging operation being interrupted by a DS update? fatzopilot Smart GWT Technical Q&A 2 4th May 2011 17:43
Mass update doesnt work for listgrid deletes? muz715 Smart GWT Technical Q&A 3 29th Apr 2011 05:28
Calling Update operation on the click of a button naiksank Smart GWT Technical Q&A 0 28th Feb 2011 03:23
update operation sends record without primary key lazinskip Smart GWT Technical Q&A 4 16th Mar 2009 04:19

© 2010,2011 Isomorphic Software. All Rights Reserved