Hi Howard, You could always work it from the other angle and create two subclasses of BigDecimal and have getters that convert on the fly in your business object or use the two subclasses directly. That way the conversion will work everywhere. Not sure how feasable that is in your case and how much you want to pollute your domain model.
Igor -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Howard, Adam Sent: Friday, June 17, 2005 5:03 PM To: [email protected] Subject: [Wicket-user] Semantic Type Conversion Hi All, I'm trying to Zen the best solution to my problem and I thought I'd check with the list to see if anyone else has tackled this. I have two properties in my business object that are stored as BigDecimals. One represents money and the other a percentage. I have registered a BigDecimal converter at the application level but these two pieces of data should really be formatted differently when displayed in, say, a list. I've created two IConverters, MoneyToStringConverter and PercentToStringConverter, and I have attached them to the Label components as such: listItem.add(new Label("surcharge", new Model(project.getSurcharge())) { public IConverter getConverter() { return new MoneyToStringConverter(); } }); listItem.add(new Label("surchargePercent", new Model(project.getSurchargePercent())) { public IConverter getConverter() { return new PercentToStringConverter(); } }); And this works. Surcharge is displayed as $50.00 and Surcharge Percent is displayed as 50.00%. But this seems rather tedious if I have to attach these to every field that needs conversion for display. Does anyone have any thoughts on how we could "flag" a field or label as being a specific semantic type? Should I create a MoneyLabel and a PercentLabel? Any ideas would be appreciated! -- Adam A language that doesn't affect the way you think about programming is not worth knowing. -- Alan J. Perlis ------------------------------------------------------- SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&op=ick _______________________________________________ Wicket-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/wicket-user ------------------------------------------------------- SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&op=click _______________________________________________ Wicket-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/wicket-user
