On Thu, 24. Feb 2011, Thiago H. de Paula Figueiredo wrote:

>> The resulting model contains properties with a null datatype.
> That surely looks like something you shouldn't do. How can the component  
> know how edit an value which hasn't a data type? In this case, you either 
> define a custom datatype and provide edition and viewing blocks for them  
> or you don't add this property to the bean model.

It's a simple number. Okay, not simple, but BigDecimal.

However, I did not set/change the datatype myself, as you can see in the
posted code.

>> If you need more information like how I build the PropertyConduit,
>> please let me know.
> Please post it.

private void addPropertyConduitsToBeanModel(BeanModel<TreatmentModel> model) {
   for (final ValueType valueTypes : dao.getValueTypes()) {
      PropertyConduit propertyConduit = new PropertyConduit() {
         public Object get(Object instance) {
            MyObject myObject = (MyObject) instance;
            return model.getValue(valueType);
         }

         public void set(Object instance, Object value) {
            MyObject myObject = (MyObject) instance;
            BigDecimal myValue = (BigDecimal) value;
            myObject.setValue(valueType, value);
         }

         public Class getPropertyType() {
            return BigDecimal.class;
         }

         public <T extends Annotation> T getAnnotation(Class<T> 
annotationClass) {
            return null;
         }
      };

      String propertyName = valueType.getName();
      model.add(propertyName, propertyConduit);
   }
}

- Stephan

Attachment: signature.asc
Description: Digital signature

Reply via email to