Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Except for the <strong>Dept_Id</strong> parameter, your form inputs do not match your controller parameters, so Play can't bind them. You have to make them match. For example if in your view you use <strong>courseName</strong>, in your controller you also have to use <strong>courseName</strong>.</p> <p>It's also very important that you respect <a href="http://www.oracle.com/technetwork/java/javase/documentation/codeconventions-135099.html#367" rel="nofollow">Java naming conventions</a>. It will save you from many headaches in the future.</p> <p>I have rewritten your code below with better naming :</p> <p>Model :</p> <pre><code>public class Course extends Model { public String courseName; public String courseCode; @Lob public String courseDescription; @ManyToOne public Department department; @OneToMany public List&lt;Session&gt; sessions; public Course(String courseName, String courseCode, String courseDescription, Department department){ this.courseName = courseName; this.courseCode = courseCode; this.courseDescription = courseDescription; this.department = department; } </code></pre> <p>Then the form :</p> <pre><code>#{form @Courses.save(), id:'createUser'} &lt;div&gt; Course Name: &lt;input type="text" name="courseName" /&gt; &lt;/div&gt; &lt;div&gt; Course Code: &lt;input type="text" name="courseCode" /&gt; &lt;/div&gt; &lt;div&gt; Course Description: &lt;textarea name="courseDescription" form="createUser"&gt;&lt;/textarea&gt; &lt;/div&gt; &lt;div&gt; Department Id:&lt;input type = "text" name = "departmentId" /&gt; &lt;/div&gt; &lt;div&gt; &lt;input type="submit" value="Create Course" /&gt; &lt;/div&gt; #{/form} </code></pre> <p>Then the controller :</p> <pre><code>public static void save(String courseName, String courseCode, String courseDescription, Long departmentId){ Department department = Department.findById(departmentId); Course course = new Course(courseName, courseCode, courseDescription, department); course.save(); department.addCourse(course); department.save(); index(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload