SmartGWT 中的多个字段验证失败

发布于 2024-09-27 17:23:00 字数 1701 浏览 5 评论 0原文

我试图让表单字段包含在不同数据源中定义的一个或多个元素。元素有一个数字 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

戏剧牡丹亭 2024-10-04 17:23:00
if(selectItemMultipleGrid.getValueASString ==  null){  
    SC.say("Please Select MultipleItem");  
}
if(selectItemMultipleGrid.getValueASString ==  null){  
    SC.say("Please Select MultipleItem");  
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文