private boolean calculateWithValidValues() {
   Iterator it = metaProperties.iterator();
   while (it.hasNext()) {
     MetaProperty m = (MetaProperty) it.next();
     if (m.hasValidValues()) return true;
   }
   return false;
 }
    private Object getValueWithoutWebEditorsFormat(int row, int column) {
      Object r = original.getValueAt(row, column);

      if (r instanceof Boolean) {
        if (((Boolean) r).booleanValue()) return XavaResources.getString(locale, "yes");
        return XavaResources.getString(locale, "no");
      }
      if (withValidValues) {
        MetaProperty p = getMetaProperty(column);
        if (p.hasValidValues()) {
          return p.getValidValueLabel(locale, original.getValueAt(row, column));
        }
      }

      if (r instanceof java.util.Date) {
        MetaProperty p =
            getMetaProperty(column); // In order to use the type declared by the developer
        // and not the one returned by JDBC or the JPA engine
        if (java.sql.Time.class.isAssignableFrom(p.getType())) {
          return DateFormat.getTimeInstance(DateFormat.SHORT, locale).format(r);
        }
        if (java.sql.Timestamp.class.isAssignableFrom(p.getType())) {
          DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
          return dateFormat.format(r);
        }
        return DateFormat.getDateInstance(DateFormat.SHORT, locale).format(r);
      }

      if (r instanceof BigDecimal) {
        return formatBigDecimal(r, locale);
      }

      return r;
    }
Example #3
0
 public String changePropertiesByCMPAttributes(String source) throws XavaException {
   StringBuffer r = new StringBuffer(source);
   int i = r.toString().indexOf("${");
   int f = 0;
   while (i >= 0) {
     f = r.toString().indexOf("}", i + 2);
     if (f < 0) break;
     String property = r.substring(i + 2, f);
     String cmpAttribute = null;
     if (property.indexOf('.') >= 0) {
       cmpAttribute = "o._" + Strings.firstUpper(Strings.change(property, ".", "_"));
     } else {
       MetaProperty metaProperty = getMetaModel().getMetaProperty(property);
       if (metaProperty.getMapping().hasConverter()) {
         cmpAttribute = "o._" + Strings.firstUpper(property);
       } else {
         cmpAttribute = "o." + property;
       }
     }
     r.replace(i, f + 1, cmpAttribute);
     i = r.toString().indexOf("${");
   }
   return r.toString();
 }