Hi all,
I've been over all the DDC examples but am still stumped by this one. I have a model (pojo) which holds user preferences, the preference for each item being an Integer.
ie
public class UserPreferences {
int preferenceOne;
int preferenceTwo
constructor
getters and setters for the ints above
}
I now want to render a form that has a DDC for each of the preferences
in my model. The list of choices that needs to go into the DDC should
come from a HashMap or similar (in reality it will come from a
database) because I want to store the number attached to the item
selected, not the display string.
ie
LinkedHashMap choices = new LinkedHashMap()
choices.put("43", "Something");
choices.put("64", "Something else");
choices.put("87", "blah");
which should render the select list as:
<select name="preferenceOne">
<option value="43">Choice Something</option>
<option value="64">Choice Something else</option>
<option value="87">blah</option>
<select>
When clicking submit, the value (ie 43) should be attached to the
relevant item in the Model (ie preferenceOne would be 43), then I can
save it to the database.
Everything I've tried with ChoiceRenderer etc seems to get mixed up with the different data models etc.
Can someone please present a snippet of code on how to do this, I'm at my wits end. I cannot for the life of me find any explicit info separating the models/data as above.
thanks, Steve
smime.p7s
Description: S/MIME cryptographic signature
