Heya, I'm trying to figure out the "best" way of handling drop down choices.
It seems a bit overcomplicated and I'm not sure we're using them in the
correct way?!!
The database function to retrieve my data will be:
List<FixedCharges> listFc = enquiryController.getAvailableFixedCharges("");
....
So I now have a list of primitive hibernate objects with lots of getters and
setters.
....
I want my dropdownchoice to use more than one field from my original
FixedCharges list for the description, so the text in the description field
is...
fixedCharges.getDescription() + " - " + fixedCharges.getValue();
The key value I want returned though, is the unique key from that
table/object - fixedCharges.getFChargeCode();
....
I've already worked out a couple of ways to do it, but I don't like either
of them!!
My first way was to iterate through the fixedcharges list and create a
DropDownItem array before adding it to the form. This seems an unnecessary
iteration and I'd quite like to have the full fixedCharge object back when
the form is submitted (which this method prevents - I have to go and
reselect it from the database).
My second way was to try to use a separate custom IChoiceRenderer class, but
I don't really like this method either, it seems very complex and difficult
to extend to a general case scenario. I don't really want to have
bazillions of IChoiceRenderer implementations one for every class I want a
drop down list on. Maybe I could have an implementation of the
IChoiceRenderer as an unnamed inner class (which would be best I think) but
I can't figure out how you do this.
What's the best way to do it? It must be a reasonably common problem.
Cheers!
--
View this message in context:
http://www.nabble.com/DropDownChoice-confusion%21-tp22621465p22621465.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]