I checked a lot of sources but couldn't get the whole picture of how this is done.
I created a MulitSelect Listbox on a View which I expect to correspond to its relevant POJO's field with data type 'List' e.g. List<Med> meds = new ArrayList<Med>();
In another words, I want it to auto-persist end-users' multi-selected values from the MultiSelect Listbox to a MySQL database table.
I also have a OneToMany mapping association for Patient<->Med (1:M). That didn't work either.
I am not exactly sure how I can achieve this. Any info would be greatly appreciated.
POJO Class: Patient
Code:
@Configurable
@XStreamAlias("Patient")
@Entity
public class Patient {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "pat_id")
private Long patId;
public long getPatId() {
return patId;
}
public void setPatId(long patId) {
this.patId = patId;
}
@OneToMany(targetEntity=Med.class, cascade = CascadeType.ALL, mappedBy = "patient")
private List<Med> mMeds = new ArrayList<Med>();
..............
@CollectionOfElements
private List<Med> meds = new ArrayList<Med>();
......... gets/sets
Patient View: create.jspx
Code:
...
<div id="roo_patient_meds">
<label for="_med_id">Meds in system:</label>
<spring:bind path="med">
<form:select id="meds" path="med">
<form:option value="One">One</form:option>
<form:option value="Two">Two</form:option>
<form:option value="Three">Three</form:option>
</form:select>
</spring:bind>
<script type="text/javascript"> Spring.addDecoration(new Spring.ElementDecoration({elementId : "meds",
widgetType : "dijit.form.MultiSelect", widgetAttrs : {autocomplete : true, required : true,
trim : true, promptMessage : "Select Meds", invalidMessage : ""}}));
<script type="text/javascript">
dojo.require("dijit.form.MultiSelect");
</script>
</div>
<br/>
<div class="submit" id="patient_submit">
.........
Any info, ideas, suggestions,... will be most appreciated.
Many Thanks...Mimi