Announcement Announcement Module
Collapse
No announcement yet.
Form binding with JList and Combobox Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Form binding with JList and Combobox

    I have dialog box looks like the following:
    http://img183.imageshack.us/img183/2...ydialogji1.png

    and have following classes to bind the components in the form
    Code:
    class  DeliveryScheculeBean {
    	private Company company;
    	private List<Date> deliveryDates;
    }
    
    class Company {
       private String name;
       private Address address;
    }
    
    class Address {
        private String street;
        private String city;
        private String state;
        private String zipCode;
    }
    I would like to bind DeliveryScheduleBean.comapany with the item selected in JCombobox with Comapany objects, displaying name. JCombobox is populated with Company objects retrieved from database, and JList is populated with Date objects available for the selected company from the JCombobox.

    when user click on OK button, how do I get the DeliveryScheduleBean pupulated with selected company object, and available dates in the JList using TitledPageDialogBox.

    looking for example binding of combobox, and jlist.
    Last edited by pkbhavani; Jul 30th, 2008, 01:27 PM.

  • #2
    You have multiple options, a ListSelectionDialogBinder (explained at http://spring-rich.blogspot.com/) combines a combobox with auto-type filtering, or you could look at the source code of jpetstore, there are some other binding types there, eg the ShuffleListBinder is also very usefull. In all cases, your Form class will contain only a few lines of code, also in jpetstore are a few examples how JComponents can be autobound to certain class types, eg JXDatePicker to a Date.class, etc.

    Comment


    • #3
      To further simplify, dialog box is as follows
      http://img175.imageshack.us/img175/5...dialog2wg9.png

      can anyone give me an example of binding JList with arrayList of Date objects in DeliveryScheculeBean

      Comment


      • #4
        If you do not need the user to choose for a delivery date within the JList, you can probably populate your bean as you populate your JList.

        What you could do is to retrieve the ValueModel of the "company" property, add a change listener on it, and each time it changes, populate the JList and populate the ValueModel of the "deliveryDates" property.

        Hope this help!

        Comment

        Working...
        X