Bind objects in a Set collection

后端 未结 2 709
轮回少年
轮回少年 2020-12-17 21:17

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 prope

相关标签:
2条回答
  • 2020-12-17 21:51

    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.

    0 讨论(0)
  • 2020-12-17 22:04

    Can't you use the old syntax in the form tags and add a getter that will return a set of objects?

    public class MyObject(){
      List<OtherObject> otherObjectsList = new ArrayList<OtherObjects>();
    
      public Set<OtherObject> getOtherObject()
      {
        return new HashSet<OtherObject>(otherObjectsList);
      }
    }
    
    0 讨论(0)
提交回复
热议问题