Re: DropDownChoice ID's
I was missing the fact the values are looked up. Your right, I do not care if the values are 1,2,3... as long as I get the right stuff in my Model John Krasnay wrote: Why do you care what the id's are? Wicket doesn't store the ID anywhere, it just uses the ID to look up the list element to put into the model. jk On Sun, May 10, 2009 at 08:08:30AM -0700, Oblivian wrote: After changing genders from ListGender to ListString, I'm seeing the opposite behaviour. The values are coming across as ['m','f'] but the id's are ['0','1'] Overriding getIdValues() instead of getDisplayValues() seems to work. John Krasnay wrote: The golden rule of DropDownChoice is that the values in the list must be the same as the property you are trying to set. In your case, if you want basicDemographicInfo.gender to be set to m or f, you must pass the DropDownChoice the list [ m, f ]. You'll then need a renderer that produces the appropriate display value: new ChoiceRender() { public Object getDisplayValue(Object value) { // here, value will be m or f // look up and return Male or Female accordingly } } You shouldn't care about the ID value. The default provided by ChoiceRenderer should be fine. jk On Sat, May 09, 2009 at 05:52:29PM -0700, Oblivian wrote: basicDemographicInfo.gender is a String and genders is ListString John Krasnay wrote: What is the type of the gender property of BasicDemographicInfo? jk On Sat, May 09, 2009 at 12:39:58PM -0700, Oblivian wrote: Not sure what I'm doing wrong. I need a DropDownChoice with ... option value=fFemale/option option value=mMale/option have a basic class like this ... public class Gender implements Serializable { String id; String name; public Gender(); public Gender(String id, String name); public String getId(); public void setId(String id); public void setName(String name); } A custom ChoiceRenderer ... public class GenderChoiceRenderer implements IChoiceRenderer { public Object getDisplayValue(Object arg0) { return ((Gender) arg0).getName(); } public String getIdValue(Object arg0, int arg1) { // Sometimes this is a String if(arg0 instanceof String){ return (String)arg0; } if (Utility.isNull(arg0)){ return null; } // Other times it is not. return ((Gender) arg0).getId(); } } -- Finally in my Form... add(new DropDownChoice(gender, new PropertyModel(model, basicDemographicInfo.gender), genders, new GenderChoiceRender())); Viewing the HTML, the id's are correct m and f, however in onSubmit, I get this. model.getBasicDemographicInfo().getGender() = com.spinn.sdk.db.model.gen...@30ea3e3c Oblivian wrote: List test = Arrays.asList(new String[] { A, B, C }); add(new DropDownChoice(test, test)); How can I make the Id's match the Values? There coming through as 1,2,3. I've tried custom ChoiceRenderer, but seem to be missing something. Any help is appreciated. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- View this message in context: http://www.nabble.com/DropDownChoice-ID%27s-tp23453868p23463880.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- View this message in context: http://www.nabble.com/DropDownChoice-ID%27s-tp23453868p23466101.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- View this message in context: http://www.nabble.com/DropDownChoice-ID%27s-tp23453868p23470952
Re: TextField in ListView
public class BasicInfoForm extends Form { private static final Log log = LogFactory.getLog(BasicInfoForm.class); @SpringBean(name = spinnDao) private ISpinnDao spinnDao; @SpringBean(name = phrInfoDao) private IPhrInfoDao phrInfoDao; private LinkedHashMapString, String genders; private LinkedHashMapString, String countries; private static ListString titles = Arrays.asList(new String[] { Mr., Mrs, Ms. }); public BasicInfoForm(String id, IModel model) { super(id, model); /* Maps for DropDownChoice Lookup */ try { countries = spinnDao.getCountries(); } catch (DaoException e) { log.error(e, e.getCause()); error(Error Retreiving Countries.); } try { genders = spinnDao.getGenders(); } catch (DaoException e) { log.error(e, e.getCause()); error(Error Retreiving Genders.); } /* Models for DropDownChoice */ IModel bloodtypes = new LoadableDetachableModel() { public Object load() { ListString model = new ArrayList(); try { model = spinnDao.getBloodtypes(); } catch (DaoException e) { log.error(e, e.getCause()); error(Error Retreiving Blood Types.); } return model; } }; IModel states = new LoadableDetachableModel() { public Object load() { ListString model = new ArrayList(); try { model = spinnDao.getStates(); } catch (DaoException e) { log.error(e, e.getCause()); error(Error Retreiving States.); } return model; } }; IModel religions = new LoadableDetachableModel() { public Object load() { ListString model = new ArrayList(); try { model = spinnDao.getReligions(); } catch (DaoException e) { log.error(e, e.getCause()); error(Error Retreiving Religions.); } return model; } }; IModel languages = new LoadableDetachableModel() { public Object load() { ListLanguage model = new ArrayListLanguage(); try { model = spinnDao.getSpokenLanguages(); } catch (DaoException e) { log.error(e, e.getCause()); error(Error Retreiving Ethnicitiess.); } return model; } }; IModel ethnicities = new LoadableDetachableModel() { public Object load() { ListString model = new ArrayList(); try { model = spinnDao.getEthnicities(); } catch (DaoException e) { log.error(e, e.getCause()); error(Error Retreiving Ethnicitiess.); } return model; } }; IModel countryChoices = new LoadableDetachableModel() { public Object load() { ListString countryKeys = new ArrayList(); SetString keys = countries.keySet(); for (String key : keys) { countryKeys.add(key); } return countryKeys; }
Re: TextField in ListView
Such a simple fix. Thanks, it works! igor.vaynberg wrote: you need to chan your models IModel email = item.getModel(); item.add(new TextField(email, new PropertyModel(email, address))); item.add(new CheckBox(primary, new PropertyModel(email, isPrimary))); also if you use an LDM for the list you are most likely better off using dataview -igor On Mon, May 11, 2009 at 5:48 PM, Chris ch...@carlsoncentral.com wrote: I have a ListView that contains a TextField and Checkbox. The model is properly populating the components in populateItem(), however onSubmit() in not seeing changes. Do I have to do anything special to make changes to FormComponents in a ListView make it back into the Model? add(new ListView(emails, new PropertyModel(model, personalContactInfo.email)) { protected void populateItem(ListItem item) { Email email = (Email) item.getModel().getObject(); item.add(new TextField(email, new PropertyModel(email, address))); item.add(new CheckBox(primary, new PropertyModel(email, isPrimary))); } }); model is LoadableDetachableModel. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- View this message in context: http://www.nabble.com/TextField-in-ListView-tp23494369p23494788.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: TextField in ListView
Also do you have any idea why my language ListMultipleChoice is not defaulting to the selected values. languages is ListLanguage basicDemographicInfo.language is also ListLanguage Thanks again. igor.vaynberg wrote: you need to chan your models IModel email = item.getModel(); item.add(new TextField(email, new PropertyModel(email, address))); item.add(new CheckBox(primary, new PropertyModel(email, isPrimary))); also if you use an LDM for the list you are most likely better off using dataview -igor On Mon, May 11, 2009 at 5:48 PM, Chris ch...@carlsoncentral.com wrote: I have a ListView that contains a TextField and Checkbox. The model is properly populating the components in populateItem(), however onSubmit() in not seeing changes. Do I have to do anything special to make changes to FormComponents in a ListView make it back into the Model? add(new ListView(emails, new PropertyModel(model, personalContactInfo.email)) { protected void populateItem(ListItem item) { Email email = (Email) item.getModel().getObject(); item.add(new TextField(email, new PropertyModel(email, address))); item.add(new CheckBox(primary, new PropertyModel(email, isPrimary))); } }); model is LoadableDetachableModel. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- View this message in context: http://www.nabble.com/TextField-in-ListView-tp23494369p23494845.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: DropDownChoice ID's
After changing genders from ListGender to ListString, I'm seeing the opposite behaviour. The values are coming across as ['m','f'] but the id's are ['0','1'] Overriding getIdValues() instead of getDisplayValues() seems to work. John Krasnay wrote: The golden rule of DropDownChoice is that the values in the list must be the same as the property you are trying to set. In your case, if you want basicDemographicInfo.gender to be set to m or f, you must pass the DropDownChoice the list [ m, f ]. You'll then need a renderer that produces the appropriate display value: new ChoiceRender() { public Object getDisplayValue(Object value) { // here, value will be m or f // look up and return Male or Female accordingly } } You shouldn't care about the ID value. The default provided by ChoiceRenderer should be fine. jk On Sat, May 09, 2009 at 05:52:29PM -0700, Oblivian wrote: basicDemographicInfo.gender is a String and genders is ListString John Krasnay wrote: What is the type of the gender property of BasicDemographicInfo? jk On Sat, May 09, 2009 at 12:39:58PM -0700, Oblivian wrote: Not sure what I'm doing wrong. I need a DropDownChoice with ... option value=fFemale/option option value=mMale/option have a basic class like this ... public class Gender implements Serializable { String id; String name; public Gender(); public Gender(String id, String name); public String getId(); public void setId(String id); public void setName(String name); } A custom ChoiceRenderer ... public class GenderChoiceRenderer implements IChoiceRenderer { public Object getDisplayValue(Object arg0) { return ((Gender) arg0).getName(); } public String getIdValue(Object arg0, int arg1) { // Sometimes this is a String if(arg0 instanceof String){ return (String)arg0; } if (Utility.isNull(arg0)){ return null; } // Other times it is not. return ((Gender) arg0).getId(); } } -- Finally in my Form... add(new DropDownChoice(gender, new PropertyModel(model, basicDemographicInfo.gender), genders, new GenderChoiceRender())); Viewing the HTML, the id's are correct m and f, however in onSubmit, I get this. model.getBasicDemographicInfo().getGender() = com.spinn.sdk.db.model.gen...@30ea3e3c Oblivian wrote: List test = Arrays.asList(new String[] { A, B, C }); add(new DropDownChoice(test, test)); How can I make the Id's match the Values? There coming through as 1,2,3. I've tried custom ChoiceRenderer, but seem to be missing something. Any help is appreciated. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- View this message in context: http://www.nabble.com/DropDownChoice-ID%27s-tp23453868p23463880.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- View this message in context: http://www.nabble.com/DropDownChoice-ID%27s-tp23453868p23466101.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- View this message in context: http://www.nabble.com/DropDownChoice-ID%27s-tp23453868p23470952.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: DropDownChoice ID's
Not sure what I'm doing wrong. I need a DropDownChoice with ... option value=fFemale/option option value=mMale/option have a basic class like this ... public class Gender implements Serializable { String id; String name; public Gender(); public Gender(String id, String name); public String getId(); public void setId(String id); public void setName(String name); } A custom ChoiceRenderer ... public class GenderChoiceRenderer implements IChoiceRenderer { public Object getDisplayValue(Object arg0) { return ((Gender) arg0).getName(); } public String getIdValue(Object arg0, int arg1) { // Sometimes this is a String if(arg0 instanceof String){ return (String)arg0; } if (Utility.isNull(arg0)){ return null; } // Other times it is not. return ((Gender) arg0).getId(); } } -- Finally in my Form... add(new DropDownChoice(gender, new PropertyModel(model, basicDemographicInfo.gender), genders, new GenderChoiceRender())); Viewing the HTML, the id's are correct m and f, however in onSubmit, I get this. model.getBasicDemographicInfo().getGender() = com.spinn.sdk.db.model.gen...@30ea3e3c Oblivian wrote: List test = Arrays.asList(new String[] { A, B, C }); add(new DropDownChoice(test, test)); How can I make the Id's match the Values? There coming through as 1,2,3. I've tried custom ChoiceRenderer, but seem to be missing something. Any help is appreciated. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- View this message in context: http://www.nabble.com/DropDownChoice-ID%27s-tp23453868p23463880.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: DropDownChoice ID's
basicDemographicInfo.gender is a String and genders is ListString John Krasnay wrote: What is the type of the gender property of BasicDemographicInfo? jk On Sat, May 09, 2009 at 12:39:58PM -0700, Oblivian wrote: Not sure what I'm doing wrong. I need a DropDownChoice with ... option value=fFemale/option option value=mMale/option have a basic class like this ... public class Gender implements Serializable { String id; String name; public Gender(); public Gender(String id, String name); public String getId(); public void setId(String id); public void setName(String name); } A custom ChoiceRenderer ... public class GenderChoiceRenderer implements IChoiceRenderer { public Object getDisplayValue(Object arg0) { return ((Gender) arg0).getName(); } public String getIdValue(Object arg0, int arg1) { // Sometimes this is a String if(arg0 instanceof String){ return (String)arg0; } if (Utility.isNull(arg0)){ return null; } // Other times it is not. return ((Gender) arg0).getId(); } } -- Finally in my Form... add(new DropDownChoice(gender, new PropertyModel(model, basicDemographicInfo.gender), genders, new GenderChoiceRender())); Viewing the HTML, the id's are correct m and f, however in onSubmit, I get this. model.getBasicDemographicInfo().getGender() = com.spinn.sdk.db.model.gen...@30ea3e3c Oblivian wrote: List test = Arrays.asList(new String[] { A, B, C }); add(new DropDownChoice(test, test)); How can I make the Id's match the Values? There coming through as 1,2,3. I've tried custom ChoiceRenderer, but seem to be missing something. Any help is appreciated. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- View this message in context: http://www.nabble.com/DropDownChoice-ID%27s-tp23453868p23463880.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- View this message in context: http://www.nabble.com/DropDownChoice-ID%27s-tp23453868p23466101.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: DropDownChoice ID's
basicDemographicInfo.gender is a String and genders is ListGender Oblivian wrote: List test = Arrays.asList(new String[] { A, B, C }); add(new DropDownChoice(test, test)); How can I make the Id's match the Values? There coming through as 1,2,3. I've tried custom ChoiceRenderer, but seem to be missing something. Any help is appreciated. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- View this message in context: http://www.nabble.com/DropDownChoice-ID%27s-tp23453868p23466110.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: DropDownChoice ID's
basicDemographicInfo.gender is a String and genders is ListGender John Krasnay wrote: What is the type of the gender property of BasicDemographicInfo? jk On Sat, May 09, 2009 at 12:39:58PM -0700, Oblivian wrote: Not sure what I'm doing wrong. I need a DropDownChoice with ... option value=fFemale/option option value=mMale/option have a basic class like this ... public class Gender implements Serializable { String id; String name; public Gender(); public Gender(String id, String name); public String getId(); public void setId(String id); public void setName(String name); } A custom ChoiceRenderer ... public class GenderChoiceRenderer implements IChoiceRenderer { public Object getDisplayValue(Object arg0) { return ((Gender) arg0).getName(); } public String getIdValue(Object arg0, int arg1) { // Sometimes this is a String if(arg0 instanceof String){ return (String)arg0; } if (Utility.isNull(arg0)){ return null; } // Other times it is not. return ((Gender) arg0).getId(); } } -- Finally in my Form... add(new DropDownChoice(gender, new PropertyModel(model, basicDemographicInfo.gender), genders, new GenderChoiceRender())); Viewing the HTML, the id's are correct m and f, however in onSubmit, I get this. model.getBasicDemographicInfo().getGender() = com.spinn.sdk.db.model.gen...@30ea3e3c Oblivian wrote: List test = Arrays.asList(new String[] { A, B, C }); add(new DropDownChoice(test, test)); How can I make the Id's match the Values? There coming through as 1,2,3. I've tried custom ChoiceRenderer, but seem to be missing something. Any help is appreciated. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- View this message in context: http://www.nabble.com/DropDownChoice-ID%27s-tp23453868p23463880.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- View this message in context: http://www.nabble.com/DropDownChoice-ID%27s-tp23453868p23466542.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Forms loading multiple times
I mean the DAO that populates my model, runs 2 times. Oblivian wrote: I'm having a issue with forms loading multiple times.. This is really screwing up ChoiceRenderer. Has anyone else experienced this? - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- View this message in context: http://www.nabble.com/Forms-loading-multiple-times-tp23449346p23453892.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: DropDownChoice ID's
Think I figured it out by doing something like this. Is this the right way? public class StringChoiceRender implements IChoiceRenderer { public Object getDisplayValue(Object object) { return object.toString(); } public String getIdValue(Object object, int index) { return object.toString(); } } Oblivian wrote: List test = Arrays.asList(new String[] { A, B, C }); add(new DropDownChoice(test, test)); How can I make the Id's match the Values? There coming through as 1,2,3. I've tried custom ChoiceRenderer, but seem to be missing something. Any help is appreciated. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- View this message in context: http://www.nabble.com/DropDownChoice-ID%27s-tp23453868p23454055.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: DropDownChoice ID's
Thanks. Oblivian wrote: List test = Arrays.asList(new String[] { A, B, C }); add(new DropDownChoice(test, test)); How can I make the Id's match the Values? There coming through as 1,2,3. I've tried custom ChoiceRenderer, but seem to be missing something. Any help is appreciated. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- View this message in context: http://www.nabble.com/DropDownChoice-ID%27s-tp23453868p23454080.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org