Closed estefaniamiguel closed 8 years ago
DateAdapter changed to DateTransformer. Now you should always use transformer object. The only exceptions are [selector and other kinds of] items:
val propiedadModelos = bindItems(new ObservableProperty(homeModelos, "modelos"))
propiedadModelos.adaptWith(typeof(Modelo), "descripcionEntera") // option A
propiedadModelos.adapter = new PropertyAdapter(typeof(Modelo), "descripcionEntera") // option B
That's because of the different nature of items vs. other widgets. If you try to define a transformer for an item
val propiedadModelos = bindItems(new ObservableProperty(homeModelos, "modelos"))
propiedadModelos.transformer = new ValueTransformer<Modelo, String>() {
override getModelType() {
typeof(Modelo)
}
override getViewType() {
typeof(String)
}
override modelToView(Modelo valueFromModel) {
valueFromModel.descripcionEntera
}
override viewToModel(String valueFromView) {
null
}
}
you get this error:
java.lang.UnsupportedOperationException: Applying transformers to item bindings is currently not supported.
at org.uqbar.lacar.ui.impl.jface.lists.JFaceItemsBindingBuilder.adaptWith(JFaceItemsBindingBuilder.java:32)
at org.uqbar.lacar.ui.model.bindings.Binding$1.configure(Binding.java:59)
at org.uqbar.lacar.ui.model.bindings.Binding.execute(Binding.java:127)
at org.uqbar.arena.widgets.Widget.showOn(Widget.java:95)
Students get confused over where they should use transformer and where adapter. You can use -bindValueToProperty("fecha").transformer = new DateAdapter or -bindContentsToProperty("modeloCelular").transformer
But -bindContentsToProperty("modeloCelular").adapter does not exists
And on the selector we can do: -bindItems(new ObservableProperty(homeModelos, "modelos")).adapter = new PropertyAdapter(typeof(Modelo), "descripcionEntera")
I don't know if this is on purpose but it is so confusing... Can't we do anything about it?