绑定 Set 集合中的对象 [英] Bind objects in a Set collection
问题描述
我有一个表单来填充集合的一些对象.我用 List 实现了集合(一切正常),但现在我想使用 Set.我注册了一个属性编辑器来创建对象.问题是我不知道我必须使用什么语法来填充 Set 的对象.
I have a form which fills some objects of a Collection. I had the collection implemented with a List (an everything worked good), but now I want to use a Set. I have a property editor registered to create the objects. The problem is that I don't know what is the syntax I must use to populate the objects of the Set.
public class MyObject(){
Set<OtherObject> otherObjects = new HashSet();
}
我尝试过使用表单标签中的语法,比如列表中的语法:
I have tried with the syntax in the form tags, like the syntax a list:
name="otherObjects['${status.index}']"
和地图的语法一样:
name="otherObjects['${id}']"
但两者都出现错误,因为在索引属性路径'otherObjects[0]'中引用的属性既不是数组也不是列表也不是映射"
but both come to an error because "Property referenced in indexed property path 'otherObjects[0]' is neither an array nor a List nor a Map"
我也试过
name="otherObjects"
但这不会填充对象.谁能告诉我如何将数据绑定到 Set 中的对象.
but this doesn't fill the objects. Can anyone tell me how to bind the data to the objects in a Set.
谢谢
推荐答案
根据关于数据绑定的文档,您只能使用括号表示法绑定到自然有序集合"中的嵌套对象.一组不合格.
According to the documentation on data binding, you can only user the bracket notation to bind to nested objects in a "naturally ordered collection". A set doesn't qualify.
这篇关于绑定 Set 集合中的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!