0 Replies - 558 Views - Last Post: 10 February 2018 - 12:37 PM

#1 ibnmvungi   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 93
  • Joined: 20-April 12

AUTO SELECT CHECKBOXES SPRING MVC

Posted 10 February 2018 - 12:37 PM

Hallo there.

I have model

@Entity
@Table(name = "User")
class User {
 private static final long serialVersionUID = 124321412342134213L;
    @Id
    @SequenceGenerator(name = "st_id_seq", sequenceName = "st_id_seq", allocationSize = 1)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "st_id_seq")
    @Column(name = "id", updatable = false)
    private Long id;
    private String name;

  @JoinTable(name = "user_courses", joinColumns = {
        @JoinColumn(name = "user_id", referencedColumnName = "id")}, inverseJoinColumns = {
        @JoinColumn(name = "module_id", referencedColumnName = "id")})
    @ManyToMany(fetch = FetchType.EAGER)
    private List<Course> coursesList;

....................
}


course model

@Entity
@Table(name = "course")
public class Course implements Serializable {

    private static final long serialVersionUID = -23412341234231423142L;

    @Id
    @SequenceGenerator(name = "coursed_seq", sequenceName = "coursed_seq", allocationSize = 1)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "coursed_seq")
    @Column(name = "id", updatable = false)
    private Long id;
    private String name;

.................

}


Controller

model.addAttribute("user", user);
  model.addAttribute("courses", courseService.getCourses());



View
<form:form class="form-horizontal form-label-left" modelAttribute="user">
   <form:checkboxes items="${courses}" itemValue="id" itemLabel="name" path="coursesList" element="li"></form:checkboxes>
</form:form>


Checkboxes not selected (those saved in the database). I have tried it for two days now with no luck.
Anyone with ideas?

This post has been edited by ibnmvungi: 10 February 2018 - 12:38 PM


Is This A Good Question/Topic? 0
  • +

Page 1 of 1