I have the following problem, I have a dropdownchoice component.  The load
method returns a list of Broker objects which have an id and displayName
attributes.  Although currently not in this code, I will use the
iChoiceRenderer to populate the appropriate values.  The Request instance
object is a backing object which contains brokerId as an attribute.

 

My question is it possible to populate the instance.brokerId with the broker
id that gets rendered by iChoiceRenderer.  Currently I get an ClassCast
exception because the loaded model is of type Broker and the
instance.brokerId is long.  

 

     Request instance = new Request();

     // instance has broker as a long attribute

 

  Form form = new Form("entryForm", new CompoundPropertyModel(instance));

  add(form);                      

 

        DropDownChoice broker = 

            new DropDownChoice("broker",

                    new PropertyModel(instance, "broker"),

                    new LoadableDetachableModel()

                        {

                        @Override

                        protected Object load() 

                        {

                            return ((Application) getApplication())

                                 .getBrokerDao().getUniqueBrokers();

                        }

                    }

                );

        broker.setRequired(true);

        form.add(broker);

Reply via email to