SmartGWT 中的多个字段验证失败
我试图让表单字段包含在不同数据源中定义的一个或多个元素。元素有一个数字 ID 和一个人类可读的名称。一切都很顺利,直到我尝试保存;在这种情况下,我总是收到“不是有效选项”错误。
我正在编辑的表单基于营销活动数据源,该数据源可能链接到零个或多个中继。
数据源主干定义为:
DataSourceField fId = new DataSourceField(
"trunkId", FieldType.INTEGER, "Id");
fId.setPrimaryKey(Boolean.TRUE);
fId.setHidden(Boolean.TRUE);
fId.setCanEdit(Boolean.FALSE);
DataSourceField fName = new DataSourceField(
"trunkName", FieldType.TEXT, "Name");
fName.setRequired(Boolean.TRUE);
数据源营销活动有一个字段“主干”定义为:
DataSourceField fTrunk = new DataSourceField(
"trunk",
FieldType.INTENUM,
"Trunk"
);
fTrunk.setMultiple(Boolean.TRUE);
fTrunk.setForeignKey("CfgTrunkDS.trunkId");
以下是允许选择多个值的表单定义:
final DynamicForm form = new DynamicForm();
form.setIsGroup(true);
form.setGroupTitle("Update Campaign");
form.setNumCols(4);
form.setDataSource(dsCampaign);
form.setUseAllDataSourceFields(Boolean.TRUE);
final SelectItem selectItemMultipleGrid = new SelectItem("trunk");
selectItemMultipleGrid.setTitle("Trunk to use");
selectItemMultipleGrid.setMultiple(true);
selectItemMultipleGrid.setMultipleAppearance(MultipleAppearance.PICKLIST);
selectItemMultipleGrid.setOptionDataSource(CfgTrunkDS.getInstance());
selectItemMultipleGrid.setValueField("trunkId");
selectItemMultipleGrid.setDisplayField("trunkName");
form.setFields(selectItemMultipleGrid);
我还正确地看到了多个值,如果我查看“主干”字段,我会发现当我选择 id 为 12 和 16 的元素时,看到类似“12, 16”的字符串。但仍然没有通过验证。我还注意到,如果我在表单定义中注释 OptionDataSource,它的工作原理也一样好。
我做错了什么?
I am trying to have a form field contain one or more elements that are defined in a different data source. Elements have a numeric id and a human-readable name. It all works well until I try to save; in this case, I always get the "Not a valid option" error.
The form I am editing is based on a Campaigns datasource, that may be linked to zero or more Trunks.
Datasource Trunks are defined as:
DataSourceField fId = new DataSourceField(
"trunkId", FieldType.INTEGER, "Id");
fId.setPrimaryKey(Boolean.TRUE);
fId.setHidden(Boolean.TRUE);
fId.setCanEdit(Boolean.FALSE);
DataSourceField fName = new DataSourceField(
"trunkName", FieldType.TEXT, "Name");
fName.setRequired(Boolean.TRUE);
Datasource Campaigns have a field "trunk" defined as:
DataSourceField fTrunk = new DataSourceField(
"trunk",
FieldType.INTENUM,
"Trunk"
);
fTrunk.setMultiple(Boolean.TRUE);
fTrunk.setForeignKey("CfgTrunkDS.trunkId");
And here is the form definition to allow for multiple values being selected:
final DynamicForm form = new DynamicForm();
form.setIsGroup(true);
form.setGroupTitle("Update Campaign");
form.setNumCols(4);
form.setDataSource(dsCampaign);
form.setUseAllDataSourceFields(Boolean.TRUE);
final SelectItem selectItemMultipleGrid = new SelectItem("trunk");
selectItemMultipleGrid.setTitle("Trunk to use");
selectItemMultipleGrid.setMultiple(true);
selectItemMultipleGrid.setMultipleAppearance(MultipleAppearance.PICKLIST);
selectItemMultipleGrid.setOptionDataSource(CfgTrunkDS.getInstance());
selectItemMultipleGrid.setValueField("trunkId");
selectItemMultipleGrid.setDisplayField("trunkName");
form.setFields(selectItemMultipleGrid);
I also see the multiple values correctly and if I look at the "trunk" fiels, I see a string like "12, 16" when I select elements whose ids are 12 and 16. But still does not pass validation. I also noticed that if I comment the OptionDataSource in the form definition, it works just as fine.
What did I do wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)