Hi,
I'm facing one problem in validating form when form bound with datasource.
I have a grid and form which are bound to same datasource. Form is used to insert new record to grid and update the datasource.
For datasource, i'm using GwtRPCDatasource.
I want to do primary key validation. Please find my case below:
i have a record with Project Name and Project Status fields. I've set Project Name as primary key at datasource level. The same datasource i set to form. At form level, i've set required(true) to project name field. i've added submit item to form. When i click submit, its showing required validation errors. After i correcting those errors, it should show error for primary key violation if i give the project name which already exists. But its not giving any error and submitting the form successfully.
Please find sample code below:
1) ProjectDS
===================
public class ProjectDS extends GwtRpcDataSource{
public ProjectDS(String id) {
setID(id);
DataSourceTextField projectNameField = new DataSourceTextField(FIELD_PROJECT_NAME, "Project Name");
projectNameField.setPrimaryKey(true);
DataSourceTextField statusField=new DataSourceTextField(FIELD_PROJECT_STATUS,"Status");
setFields(projectNameField,statusField);
}
2)MyForm
=============
final DynamicForm form=new DynamicForm();
form.setDataSource(projectDS);
TextItem projectNameItem=new TextItem(ProjectDS.FIELD_PROJECT_NAME,"Project Name");
projectNameItem.setRequired(true);
projectNameItem.setTooltip("Project Name");
SubmitItem btnSubmit=new SubmitItem();
form.setItems(projectNameItem,btnSubmit);
........
..............
...........
Please tell me how to do primary key violation validation at form?
I'm facing one problem in validating form when form bound with datasource.
I have a grid and form which are bound to same datasource. Form is used to insert new record to grid and update the datasource.
For datasource, i'm using GwtRPCDatasource.
I want to do primary key validation. Please find my case below:
i have a record with Project Name and Project Status fields. I've set Project Name as primary key at datasource level. The same datasource i set to form. At form level, i've set required(true) to project name field. i've added submit item to form. When i click submit, its showing required validation errors. After i correcting those errors, it should show error for primary key violation if i give the project name which already exists. But its not giving any error and submitting the form successfully.
Please find sample code below:
1) ProjectDS
===================
public class ProjectDS extends GwtRpcDataSource{
public ProjectDS(String id) {
setID(id);
DataSourceTextField projectNameField = new DataSourceTextField(FIELD_PROJECT_NAME, "Project Name");
projectNameField.setPrimaryKey(true);
DataSourceTextField statusField=new DataSourceTextField(FIELD_PROJECT_STATUS,"Status");
setFields(projectNameField,statusField);
}
2)MyForm
=============
final DynamicForm form=new DynamicForm();
form.setDataSource(projectDS);
TextItem projectNameItem=new TextItem(ProjectDS.FIELD_PROJECT_NAME,"Project Name");
projectNameItem.setRequired(true);
projectNameItem.setTooltip("Project Name");
SubmitItem btnSubmit=new SubmitItem();
form.setItems(projectNameItem,btnSubmit);
........
..............
...........
Please tell me how to do primary key violation validation at form?
Comment