Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7584315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:53:27+00:00 2026-05-30T18:53:27+00:00

Is there any way to properly bind to a Set on a form? I’m

  • 0

Is there any way to properly bind to a Set on a form?

I’m doing POJO binding and my controller takes in a User object

public static void create(User user)

user.java

public class User implements Serializable {



    public Long id;

    @Required
    @Email
    public String email;

    public Set<Group> groups;

}

Group.java

    public class Group implements Serializable {

        public Long id;

        public String name;

    }

I can’t seem to get my field to bind to groups

i’ve tried user.groups[].id, user.groups[0].id, user.groups.id. I can get it to work with a list just fine but when it posts I get a list of N elements with a bunch of null items (one null for each checkbox that was not checked) and I could just create a new list without the nulls but that seems wrong.

Edit: User and Group are not meant to be persistent entities, Play is merely acting as a stateless and persistent-less presentation layer for a restful API

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T18:53:28+00:00Added an answer on May 30, 2026 at 6:53 pm

    The new Binder implementation of Play 1.2.4 allows this.

    In Play versions earlier to 1.2.4 (released December 02, 2011) you could not bind a set by sending parameters like

    user.groups[1].id = 1
    user.groups[1].name = "name1"
    user.groups[3].id = 3
    user.groups[3].name = "name3"
    user.groups[4].id = 4
    user.groups[4].name = "name4"
    

    The problem with binding to a List is that you will get a List of length 5 where the value at 0 and 2 is null.

    If you still need to use Play version minor than 1.2.4, a workaround for this problem could be using

    Map<String, Group> groups
    

    instead of Set or List. Then you won’t get null elements in between and you will get Collection by calling groups.values().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to use binding to set the UIElement's name? I always
Is there any good way to bind a property to a const value in
Is there any way in .net to bind a dictionary of properties to an
Is there any way to bind a winform ListView to a DataTable (or perhaps
Is there any way to serialize a property with an internal setter in C#?
Is there any way to create a property like this C# property in Objective-C?
Is there any way to find out if a property is mapped to a
Is there any way to change the value of property at runtime in WPF
Is there any way to detect a change in the Text property of a
In WPF, is there any way to have the Text property of a TextBlock

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.