-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: How to auto-map MultiSelect listbox values to a POJO field?
PostPosted: Tue May 18, 2010 10:59 am 
Newbie

Joined: Tue Feb 16, 2010 6:57 pm
Posts: 17
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.