@Override public void takeValuesFromRequest(WORequest worequest, WOContext wocontext) { String format = null; try { format = (String) valueForBinding("numberformat", "0"); Number num = worequest.numericFormValueForKey(wocontext.elementID(), new NSNumberFormatter(format)); if(num != null) { setValueForBinding(num, "value"); } } catch(NumberFormatException ex) { log.error("Could not format value with pattern '{}'.", format, ex); } super.takeValuesFromRequest(worequest, wocontext); }
public String textFieldValue() { if (_textFieldValue != null) { return _textFieldValue; } Object value = value(); setValue(value); if (value == null) { return null; } else if (value instanceof String) { return (String) value; } else { java.text.Format formatter = null; String className = valueClassNameForKey(selectedKey()); if (className.equals("com.webobjects.foundation.NSTimestamp")) { String dateFormatterString = formatterForKey(selectedKey()); formatter = new NSTimestampFormatter(dateFormatterString); } else if (className.equals("java.lang.Number") || className.equals("java.math.BigDecimal")) { String numberFormatterString = formatterForKey(selectedKey()); formatter = new NSNumberFormatter(numberFormatterString); } return (formatter != null) ? formatter.format(value) : value.toString(); } }
} else if (className.equals("java.lang.Number") || className.equals("java.math.BigDecimal")) { String numberFormatterString = formatterForKey(selectedKey()); NSNumberFormatter numberFormatter = new NSNumberFormatter(numberFormatterString); Object objectValue = null; try {
/** * This class corresponds to one property. indexModel --> properties --> a property * * @param index the index * @param name the property name (a key or keypath) * @param dict the property definition form indexModel */ IndexAttribute(ERIndex index, String name, NSDictionary dict) { _name = name; _termVector = (TermVector) classValue(dict, "termVector", TermVector.class, "YES"); _store = (Store) classValue(dict, "store", Store.class, "NO"); _index = (Index) classValue(dict, "index", Index.class, "ANALYZED"); String analyzerClass = (String) dict.objectForKey("analyzer"); if (analyzerClass == null) { analyzerClass = StandardAnalyzer.class.getName(); } _analyzer = (Analyzer) create(analyzerClass); if (_analyzer == null && name.matches("\\w+_(\\w+)")) { // String locale = name.substring(name.lastIndexOf('_') + 1); } _format = (Format) create((String) dict.objectForKey("format")); String numberFormat = (String) dict.objectForKey("numberformat"); if (numberFormat != null) { _format = new NSNumberFormatter(numberFormat); } String dateformat = (String) dict.objectForKey("dateformat"); if (dateformat != null) { _format = new NSTimestampFormatter(dateformat); } }
line = request.numericFormValueForKey("line",new NSNumberFormatter("#0")); filename = request.stringFormValueForKey("filename"); errorMessage = request.stringFormValueForKey("errorMessage");