[Wicket-user] DropDownChoice from ResourceBundles
Hi everyone, I was wondering if there is a more automatic way of building a DropDownChoice out of resource bundles. Here is the case: 1- I have form inside a panel, which in turn has a dropdownchoice that has to be built with options on a resource bundle for i18n reasons. In this case Relationship type DEFAUL LANG: relationships.single=Single relationships.married=Married relationships.domesticPartenrship=Domestic Partnership relationships.registeredPartnership=Registered Partnership DEUTSCH: relationships.single=Alleine relationships.married=Gemeinsam (verheiratet) relationships.domesticPartenrship=Konkubinat relationships.registeredPartnership=Eingetragene Partnerschaft 2- I need to make the ORDINAL POSITION of the list (e.g. Married = 2, or 1+1) I suspect by the example in component reference that something like this could be done with some clever coding. f(t) - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] DropDownChoice from ResourceBundles
off the top of my head something like this might do it class mappeddropdownchoice extends dropdownchoice { private map val; public mappeddropdownchoice(string id, final map val) { super(id); this.val=val; setchoices(map.keys()); setchoicerenderer(new ichoicerenderer()) { getdisplayvalue(object o) { return val.get(o); } getidvalue(object o) { return o.tostring(); } }); } map map=new hashmap(); map.put(1, relationships.single); ... add(new mappeddropdownchoice(id,map) { boolean localizeDisplayValues() { return true; }}); -igor On 4/23/07, Francisco Diaz Trepat - gmail [EMAIL PROTECTED] wrote: Hi everyone, I was wondering if there is a more automatic way of building a DropDownChoice out of resource bundles. Here is the case: 1- I have form inside a panel, which in turn has a dropdownchoice that has to be built with options on a resource bundle for i18n reasons. In this case Relationship type DEFAUL LANG: relationships.single=Single relationships.married=Married relationships.domesticPartenrship =Domestic Partnership relationships.registeredPartnership=Registered Partnership DEUTSCH: relationships.single =Alleine relationships.married=Gemeinsam (verheiratet) relationships.domesticPartenrship=Konkubinat relationships.registeredPartnership=Eingetragene Partnerschaft 2- I need to make the ORDINAL POSITION of the list (e.g. Married = 2, or 1+1) I suspect by the example in component reference that something like this could be done with some clever coding. f(t) - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] DropDownChoice from ResourceBundles
Of the top of your head worked up fine!!! Thanks. Heres is the final code. private class MappedDropDownChoice extends DropDownChoice { private final Map mapValues; public MappedDropDownChoice(String id, final Map values) { super(id); this.mapValues=values; setChoices(new ArrayList(this.mapValues.keySet())); setChoiceRenderer(new IChoiceRenderer() { public Object getDisplayValue(Object object) { return mapValues.get(object); } public String getIdValue(Object object, int index) { return object.toString(); } }); } public boolean localizeDisplayValues(){ return true; } } Thanks again. wicket rulez] _ _ On 4/23/07, Igor Vaynberg [EMAIL PROTECTED] wrote: off the top of my head something like this might do it class mappeddropdownchoice extends dropdownchoice { private map val; public mappeddropdownchoice(string id, final map val) { super(id); this.val=val; setchoices(map.keys()); setchoicerenderer(new ichoicerenderer()) { getdisplayvalue(object o) { return val.get(o); } getidvalue(object o) { return o.tostring(); } }); } map map=new hashmap(); map.put(1, relationships.single); ... add(new mappeddropdownchoice(id,map) { boolean localizeDisplayValues() { return true; }}); -igor On 4/23/07, Francisco Diaz Trepat - gmail [EMAIL PROTECTED] wrote: Hi everyone, I was wondering if there is a more automatic way of building a DropDownChoice out of resource bundles. Here is the case: 1- I have form inside a panel, which in turn has a dropdownchoice that has to be built with options on a resource bundle for i18n reasons. In this case Relationship type DEFAUL LANG: relationships.single=Single relationships.married=Married relationships.domesticPartenrship =Domestic Partnership relationships.registeredPartnership=Registered Partnership DEUTSCH: relationships.single =Alleine relationships.married=Gemeinsam (verheiratet) relationships.domesticPartenrship=Konkubinat relationships.registeredPartnership=Eingetragene Partnerschaft 2- I need to make the ORDINAL POSITION of the list (e.g. Married = 2, or 1+1) I suspect by the example in component reference that something like this could be done with some clever coding. f(t) - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user