class localemodel exnteds imodel {
private Locale locale;
private IModel productModel;
public localemodel(Locale locale, IModel pm) { this.locale=locale;
this.productModel=pm; }
public Object getObject() {
return ((Product)pm.getObject()).getName(locale);
}
public void setObject(Object o) {
((Product)productModel.getObject()).setName(locale, ((String)o);
}
public void detach() {
productModel.detach();
}
}
IModel productModel=new Model(new Product());
add(new TextField("french", new localemodel(Local.FR, productModel));
add(new TextField("english", new localemodel(Local.EN, productModel));
lots of shortcuts are possible if you get comfy with stuff like this.
-igor
On 4/15/07, Dreamage <[EMAIL PROTECTED]> wrote:
Hi,
I would like to know if there is a way in wicket to have a model use
getter/setter with parameters. Have a look at my example below; I have a
bean called Product with a "name" property, but it's stored in a map using
a
java.util.Locale as a key. I would like to bind this property to a
textfield
using a specific Locale (for example, instanciating 2 fields in my page,
one
for to affect the English Locale value and another one for French). To do
this I have at instruct a model to call (get/set)name using a predefined
Locale parameter. Is there anything like that built-in in Wicket ?
public class Product implements Serializable {
private Map<Locale, String> names = new HashMap<Locale, String>();
public String getName(Locale locale) {
return names.get(locale);
}
public void setName(Locale locale, String name) {
names.put(locale, name);
}
}
--
View this message in context:
http://www.nabble.com/Property-model-with-getter-setter-parameters-tf3582050.html#a10009353
Sent from the Wicket - User mailing list archive at Nabble.com.
-------------------------------------------------------------------------
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
[email protected]
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user