wcx6298 / smartgwt

Automatically exported from code.google.com/p/smartgwt
0 stars 0 forks source link

clientOnly DataSource does not report primaryKey collision #665

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
public void onModuleLoad() {
    VLayout canvas = new VLayout();
    canvas.setWidth(300);
    canvas.setLeft(20);
    canvas.setHeight(500);

    final ListGrid listGrid = new ListGrid();
    listGrid.setAlternateRecordStyles(true);
    listGrid.setEmptyMessage("Empty list!");
    listGrid.setAutoFetchData(true);

    DataSourceIntegerField areaField = new DataSourceIntegerField("area", "Area");
    DataSourceTextField nameField = new DataSourceTextField("name", "Name");
    areaField.setPrimaryKey(true);

    DataSource dataSource = new DataSource();
    dataSource.setClientOnly(true);
    dataSource.setFields(areaField, nameField);
    listGrid.setDataSource(dataSource);

    IButton addDataButton = new IButton("Add Data");
    addDataButton.setLeft(0);
    addDataButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            listGrid.startEditingNew();
        }
    });

    canvas.addMember(addDataButton);
    canvas.addMember(listGrid);

    canvas.draw();
}

What steps will reproduce the problem?
1. Click add button and put the values 1 and "hello"
2. Click add button and put the values 1 and "bye"

What is the expected output?
An error should be thrown as the first column is set as PrimaryKey which should 
have unique values.
What do you see instead?
I see both rows showing

What version of the product are you using? On what operating system?
SmartGWT 3.0

What browser(s) does this happen in?
All brwosers

if you edit the value "bye" and replace it with "welcome", it is actually 
"hello" which is replaced with "welcome

Original issue reported on code.google.com by sta191...@gmail.com on 2 Apr 2012 at 3:35

GoogleCodeExporter commented 9 years ago
Clarified summary: DataSources in general can reject colliding primaryKeys 
through normal SmartGWT error handling, although we recommend that the UI is 
constructed so that this error condition never occurs.

This issue points out that a client-only DataSource, which is basically a 
simulator of a remote DataSource, does not report such collisions - it may as 
well do so but priority is very low, especially given that you usually want to 
avoid this entirely.

Original comment by smartgwt...@gmail.com on 2 Apr 2012 at 6:10

GoogleCodeExporter commented 9 years ago
The UI I am designing gives the user the possibility to add new rows into a 
ListGrid populated by a DataSource. This is why I require the PrimaryKey to 
work in order to prevent the user from adding duplicate rows.

Will this be fixed soon?

Original comment by sta191...@gmail.com on 2 Apr 2012 at 6:43

GoogleCodeExporter commented 9 years ago
You can catch this error condition yourself by using fetchData() to detect 
duplicates, or by using a DataSource that actually makes contact with the 
server.  

So again, very low priority, will not be fixed soon unless a customer with 
support happens to ask for it.

Original comment by smartgwt...@gmail.com on 2 Apr 2012 at 6:53

GoogleCodeExporter commented 9 years ago
Sorry to bother you again but on what event should I perform the fetchData(). 
Is it the addEditCompleteHandler or something else?

Original comment by sta191...@gmail.com on 2 Apr 2012 at 7:00