1 23 24 package org.dbforms.taglib; 25 26 import org.dbforms.config.Field; 27 28 import org.dbforms.util.MessageResources; 29 30 import java.util.Locale ; 31 32 import javax.servlet.http.HttpServletRequest ; 33 34 35 36 41 public class TextFormatterUtil extends DbBaseHandlerTag { 42 private Locale locale; 43 private Object obj; 44 45 53 protected TextFormatterUtil(Field field, 54 Locale locale, 55 String pattern, 56 Object obj) { 57 this.obj = obj; 58 this.locale = locale; 59 setPattern(pattern); 60 setField(field); 61 } 62 63 73 public static String FormatText(Field field, 74 Locale locale, 75 String pattern, 76 Object obj) { 77 TextFormatterUtil tf = new TextFormatterUtil(field, locale, pattern, obj); 78 79 return tf.getFormattedFieldValue(); 80 } 81 82 83 93 public static String FormatText(Field field, 94 HttpServletRequest request, 95 String pattern, 96 Object obj) { 97 Locale locale = MessageResources.getLocale(request); 98 TextFormatterUtil tf = new TextFormatterUtil(field, locale, pattern, obj); 99 100 return tf.getFormattedFieldValue(); 101 } 102 103 104 111 public String getFormFieldName(DbFormTag parentForm) { 112 setParent(parentForm); 113 114 return super.getFormFieldName(); 115 } 116 117 118 123 public String getFormattedFieldValue() { 124 return super.getFormattedFieldValue(); 125 } 126 127 128 133 public String renderPatternHtmlInputField() { 134 return super.renderPatternHtmlInputField(); 135 } 136 137 138 143 protected Object getFieldObject() { 144 return obj; 145 } 146 147 148 153 protected Locale getLocale() { 154 return locale; 155 } 156 } 157 | Popular Tags |