problem with ValuesManager.editRecord(ListGridRecord)

Hi,

i have 3 forms, and use ValuesManger to manage them to save, update and etc.

now when i display all records in a ListGrid, and use a nested form in ListGrid to modify the record, i put the following code in the getExpansionComponent(final ListGridRecord record)

......
DynamicForm form1 = new DynamicForm();
DynamicForm form2 = new DynamicForm();

/** create modifiable fields, and load options **/
SelectItem selectAccountCode = new SelectItem("account_code", "Account Code");

/** in the datasource there's a SQL operationBinding, which requires 'parent_carrier' as a parameter **/
Criteria cri = new Criteria("parent_carrier", record.getAttribute("parent_carrier");
selectAccountCode.setPickListCriteria(cri);
selectAccountCode.setOptionDataSource(DataSource.get("account_code");
selectAccountCode.setOptionOperationId("find.account.codes.for.login.user");

ValuesManager formManager = new ValuesManager();
formManager.setDataSource(DataSource.get("datasource_name"));

formManager.addMember(form1);
formManager.addMember(form2);

formManager.editRecord(record);

This code works but throws an exception “Unknown column ‘$criteria.parent_carrier’ in ‘where clause’”. Obviously this code gets run twice, because from the server logs, i can see that it throws the exception, and the second time it gets correct criteria and returns correct results.

in the showcase, the editRecord is in

                df.addDrawHandler(new DrawHandler() {  
                    public void onDraw(DrawEvent event) {  
                        df.editRecord(record);  
                    }  
                });

this method works perfectly for DynamicForms, but ValuesManager doesn’t have such ‘onDraw’ function.

i also tried to add onDrawHandler to both form1, and form2 the problem here is that i can’t set DataSource to these forms as they have already been included by the valuesManager, but when save the form it throws a NullPointerException.

Any ideas about the problem? please help! thanks!

Problem’s solved.

i added a drawHandler to the layout where all forms are contained

		layoutForm.addDrawHandler(new DrawHandler() {
			public void onDraw(DrawEvent event) {
				formManager.editRecord(record);
			}
		});

well, it’s not really solved, it still happens occasionally. usually it works for the first expansion, but gets problem afterwards. Any idea?