1 18 package org.apache.beehive.netui.tags.html; 19 20 import org.apache.beehive.netui.util.internal.InternalStringBuilder; 21 22 import org.apache.beehive.netui.pageflow.ProcessPopulate; 23 import org.apache.beehive.netui.pageflow.RequestParameterHandler; 24 import org.apache.beehive.netui.script.common.DataAccessProviderStack; 25 import org.apache.beehive.netui.script.common.IDataAccessProvider; 26 import org.apache.beehive.netui.tags.ByRef; 27 import org.apache.beehive.netui.tags.naming.FormDataNameInterceptor; 28 import org.apache.beehive.netui.tags.naming.IndexedNameInterceptor; 29 import org.apache.beehive.netui.tags.naming.PrefixNameInterceptor; 30 import org.apache.beehive.netui.tags.rendering.*; 31 import org.apache.beehive.netui.util.Bundle; 32 import org.apache.beehive.netui.util.iterator.ArrayIterator; 33 import org.apache.beehive.netui.util.iterator.IteratorFactory; 34 import org.apache.beehive.netui.util.logging.Logger; 35 36 import javax.servlet.ServletRequest ; 37 import javax.servlet.jsp.JspException ; 38 import java.util.*; 39 40 41 211 public class Select extends HtmlOptionsDataSourceTag 212 implements IDataAccessProvider, IFormattable 213 { 214 220 private static final Logger logger = Logger.getInstance(Select.class); 221 222 private SelectTag.State _state = new SelectTag.State(); 223 private OptionTag.State _optionState = new OptionTag.State(); 224 private InputHiddenTag.State _hiddenState = new InputHiddenTag.State(); 225 private boolean _formatterError = false; 226 227 private static Object [] NULL_INSTANCE = {null}; 228 229 230 233 public static class RepeatingStages 234 { 235 private static final int INT_BEFORE = 0; 236 private static final int INT_OPTION = 1; 237 private static final int INT_DEFAULT = 2; 238 private static final int INT_DATASOURCE = 3; 239 private static final int INT_NULL = 4; 240 private static final int INT_DONE = 5; 241 242 static final RepeatingStages BEFORE = new RepeatingStages(INT_BEFORE); 243 static final RepeatingStages OPTION = new RepeatingStages(INT_OPTION); 244 static final RepeatingStages DEFAULT = new RepeatingStages(INT_DEFAULT); 245 static final RepeatingStages DATASOURCE = new RepeatingStages(INT_DATASOURCE); 246 static final RepeatingStages NULL = new RepeatingStages(INT_NULL); 247 static final RepeatingStages DONE = new RepeatingStages(INT_DONE); 248 249 253 public static final String REPEATING_OPTION = "option"; 254 public static final String REPEATING_DEFAULT = "default"; 255 public static final String REPEATING_DATASOURCE = "dataSource"; 256 public static final String REPEATING_NULL = "null"; 257 258 public int value; 259 260 private RepeatingStages(int val) 262 { 263 value = val; 264 } 265 266 int getValue() 267 { 268 return value; 269 } 270 271 275 public String toString() 276 { 277 switch (value) { 278 case INT_OPTION: 279 return REPEATING_OPTION; 280 case INT_DEFAULT: 281 return REPEATING_DEFAULT; 282 case INT_DATASOURCE: 283 return REPEATING_DATASOURCE; 284 case INT_NULL: 285 return REPEATING_NULL; 286 default: 287 return "Unknown Stage"; 288 } 289 } 290 291 296 public static RepeatingStages parseString(String value) 297 { 298 if (REPEATING_OPTION.equals(value)) 299 return OPTION; 300 if (REPEATING_DEFAULT.equals(value)) 301 return DEFAULT; 302 if (REPEATING_DATASOURCE.equals(value)) 303 return DATASOURCE; 304 if (REPEATING_NULL.equals(value)) 305 return NULL; 306 return null; 307 } 308 } 309 310 313 private static final RepeatingStages[] DEFAULT_ORDER = {RepeatingStages.BEFORE, 314 RepeatingStages.OPTION, 315 RepeatingStages.DATASOURCE, 316 RepeatingStages.DEFAULT, 317 RepeatingStages.NULL}; 318 319 322 public static final String NULL_VALUE = "netui_null"; 323 324 327 329 private static final String SELECT_KEY = "select_key"; 330 private static final String OLDVALUE_SUFFIX = "OldValue"; 331 332 private int _repIdx = 0; private RepeatingStages _repCurStage = RepeatingStages.BEFORE; private boolean _repeater; private Object _repCurItem; private Iterator _repeaterIterator; private RepeatingStages[] _order = DEFAULT_ORDER; 339 340 private Object _dynamicOptions; 342 private String _saveBody; 343 private String _nullableOptionText; 344 345 private List _defaultSelections; 346 private ArrayList _formatters; 347 private ArrayList _optionList; 348 private String [] _match; private boolean _nullable; 350 private TagRenderingBase _optRb; 351 352 private static final List _internalNamingChain; 353 354 static 355 { 356 List l = new ArrayList(3); 357 l.add(new FormDataNameInterceptor()); 358 l.add(new IndexedNameInterceptor()); 359 l.add(new PrefixNameInterceptor(SELECT_KEY)); 360 _internalNamingChain = Collections.unmodifiableList(l); 361 362 org.apache.beehive.netui.pageflow.ProcessPopulate.registerPrefixHandler(SELECT_KEY, new SelectPrefixHandler()); 363 } 364 365 367 public static class SelectPrefixHandler 368 implements RequestParameterHandler 369 { 370 public void process(javax.servlet.http.HttpServletRequest request, String key, 371 String expr, ProcessPopulate.ExpressionUpdateNode node) 372 { 373 String [] returnArray = null; 374 375 if (!key.endsWith(OLDVALUE_SUFFIX)) { 376 returnArray = request.getParameterValues(key); 378 } 379 else { 380 String newKey = key.substring(0, key.indexOf(OLDVALUE_SUFFIX)); 382 String [] select = request.getParameterValues(newKey); 383 if (select != null) { 384 returnArray = select; 385 } 386 else { 387 returnArray = new String [0]; } 389 } 390 391 if (node.expression.endsWith(OLDVALUE_SUFFIX)) { 392 node.expression = node.expression.substring(0, node.expression.indexOf(OLDVALUE_SUFFIX)); 393 } 394 395 for (int i = 0; i < returnArray.length; i++) { 397 if (returnArray[i].equals(NULL_VALUE)) { 398 returnArray[i] = null; 399 } 400 } 401 402 node.values = returnArray; 403 404 if (logger.isDebugEnabled()) { 405 logger.debug("\n*********************************************\n" + 406 "process with key \"" + key + "\" and expression \"" + node.expression + "\"" + "and result size: " 407 + (returnArray != null ? "" + returnArray.length : null) + "\n" + 408 "*********************************************\n"); 409 } 410 } 411 } 412 413 public Select() 414 { 415 super(); 416 } 417 418 421 public String getTagName() 422 { 423 return "Select"; 424 } 425 426 public String getDataSource() 427 { 428 return _dataSource.toString(); 429 } 430 431 436 protected AbstractHtmlState getState() 437 { 438 return _state; 439 } 440 441 447 protected List getNamingChain() 448 { 449 return _internalNamingChain; 450 } 451 452 455 protected Object evaluateDefaultValue() 456 throws JspException  457 { 458 Object val = _defaultValue; 459 460 List defaults = null; 461 if (val instanceof String ) { 462 defaults = new ArrayList(); 463 defaults.add(val); 464 } 465 else { 466 Iterator optionsIterator = null; 467 optionsIterator = IteratorFactory.createIterator(val); 468 469 if (optionsIterator == null && _defaultValue != null) 471 logger.warn(Bundle.getString("Tags_IteratorError", 472 new Object []{getTagName(), "defaultValue", _defaultValue})); 473 474 if (optionsIterator == null) 475 optionsIterator = IteratorFactory.EMPTY_ITERATOR; 476 477 defaults = new ArrayList(); 478 while (optionsIterator.hasNext()) { 479 Object o = optionsIterator.next(); 480 defaults.add(o.toString()); 481 } 482 } 483 484 return defaults; 485 } 486 487 500 public void setMultiple(boolean multiple) 501 { 502 _state.multiple = multiple; 503 } 504 505 514 public void setRepeater(boolean repeater) 515 { 516 _repeater = repeater; 517 } 518 519 523 public boolean isRepeater() 524 { 525 return _repeater; 526 } 527 528 545 public void setRepeatingOrder(String order) 546 throws JspException  547 { 548 String [] options = order.split(","); 549 RepeatingStages[] stageOrder = new RepeatingStages[options.length + 1]; 550 stageOrder[0] = RepeatingStages.BEFORE; 551 for (int i = 0; i < options.length; i++) { 552 String opt = options[i].trim(); 553 stageOrder[i + 1] = RepeatingStages.parseString(opt); 554 if (stageOrder[i + 1] == null) { 555 String s = Bundle.getString("Tags_SelectBadRepeatingStage", new Object []{opt}); 556 registerTagError(s, null); 557 } 558 } 559 _order = stageOrder; 560 } 561 562 574 public void setNullable(boolean nullable) 575 { 576 _nullable = nullable; 577 } 578 579 583 public Object getOptionsDataSource() 584 { 585 return _optionsDataSource; 586 } 587 588 602 public void setNullableOptionText(String nullableOptionText) 603 { 604 _nullableOptionText = nullableOptionText; 605 } 606 607 615 protected Object evaluateOptionsDataSource() 616 throws JspException  617 { 618 Object val = _optionsDataSource; 619 if (val == null) { 620 if (_optionsDataSource != null) 622 logger.warn(Bundle.getString("Tags_IteratorError", 623 new Object []{getTagName(), "optionsDataSource", _optionsDataSource})); 624 return null; 625 } 626 627 if (val instanceof Map) 628 return val; 629 630 Iterator options = null; 631 options = IteratorFactory.createIterator(val); 632 if (options == null) 633 options = IteratorFactory.EMPTY_ITERATOR; 634 635 return options; 636 } 637 638 647 public void setSize(int size) 648 { 649 _state.size = size; 650 } 651 652 656 public boolean isMatched(String value) 657 { 658 if (value == null) 659 return false; 660 if ((_match != null)) { 661 for (int i = 0; i < _match.length; i++) { 662 if (value.equals(_match[i])) 663 return true; 664 } 665 } 666 else { 667 if (_defaultSelections != null) { 668 return (_defaultSelections.contains(value)); 669 } 670 } 671 672 return false; 673 674 } 675 676 680 685 public int getCurrentIndex() 686 { 687 return _repIdx; 688 } 689 690 694 public Object getCurrentItem() 695 { 696 return _repCurItem; 697 } 698 699 708 public Object getCurrentMetadata() 709 { 710 return this; 711 } 712 713 723 public IDataAccessProvider getProviderParent() 724 { 725 return (IDataAccessProvider) findAncestorWithClass(this, IDataAccessProvider.class); 726 } 727 728 732 public RepeatingStages getRepeatingStage() 733 { 734 return _repCurStage; 735 } 736 737 741 public boolean isOptionStage() 742 { 743 return _repCurStage == RepeatingStages.OPTION; 744 } 745 746 750 public boolean isDefaultStage() 751 { 752 return _repCurStage == RepeatingStages.DEFAULT; 753 } 754 755 759 public boolean isDataSourceStage() 760 { 761 return _repCurStage == RepeatingStages.DATASOURCE; 762 } 763 764 768 public boolean isNullStage() 769 { 770 return _repCurStage == RepeatingStages.NULL; 771 } 772 773 777 public int doStartTag() throws JspException  778 { 779 Object val = evaluateDataSource(); 780 _defaultSelections = (List) evaluateDefaultValue(); 781 782 if (hasErrors()) 784 return SKIP_BODY; 785 786 buildMatch(val); 787 if (hasErrors()) 788 return SKIP_BODY; 789 790 791 _formatters = new ArrayList(); 792 _optionList = new ArrayList(); 793 794 _dynamicOptions = evaluateOptionsDataSource(); 796 if (_repeater) { 797 _repCurStage = _order[0]; 798 boolean valid = doRepeaterAfterBody(); 799 if (!valid) 800 return SKIP_BODY; 801 DataAccessProviderStack.addDataAccessProvider(this, pageContext); 802 } 803 804 return EVAL_BODY_BUFFERED; 806 } 807 808 813 public int doAfterBody() throws JspException  814 { 815 if (hasErrors()) { 816 return SKIP_BODY; 817 } 818 819 if (_repeater) { 821 if (doRepeaterAfterBody()) 822 return EVAL_BODY_AGAIN; 823 } 824 825 if (bodyContent != null) { 826 String value = bodyContent.getString(); 827 bodyContent.clearBody(); 828 if (value == null) 829 value = ""; 830 _saveBody = value.trim(); 831 } 832 return SKIP_BODY; 833 } 834 835 839 public int doEndTag() throws JspException  840 { 841 ServletRequest req = pageContext.getRequest(); 842 843 String fmtErrors = null; 844 if (_formatterError) { 845 fmtErrors = getErrorsFromBody(); 846 } 847 if (hasErrors()) 848 return reportAndExit(EVAL_PAGE); 849 850 _state.disabled = isDisabled(); 851 852 ByRef ref = new ByRef(); 854 nameHtmlControl(_state, ref); 855 856 if (hasErrors()) 857 return reportAndExit(EVAL_PAGE); 858 859 WriteRenderAppender writer = new WriteRenderAppender(pageContext); 863 if (!_state.disabled) { 864 _hiddenState.clear(); 865 String hiddenParamName = null; 866 hiddenParamName = _state.name + OLDVALUE_SUFFIX; 867 _hiddenState.name = hiddenParamName; 868 _hiddenState.value = "true"; 869 870 TagRenderingBase hiddenTag = TagRenderingBase.Factory.getRendering(TagRenderingBase.INPUT_HIDDEN_TAG, req); 871 hiddenTag.doStartTag(writer, _hiddenState); 872 hiddenTag.doEndTag(writer); 873 write("\n"); 874 } 875 876 if (fmtErrors != null) 878 write(fmtErrors); 879 880 881 TagRenderingBase br = TagRenderingBase.Factory.getRendering(TagRenderingBase.SELECT_TAG, req); 882 br.doStartTag(writer, _state); 883 884 if (_saveBody != null) { 886 write(_saveBody); 887 } 888 889 if (_repeater) { 891 892 if (hasErrors()) 893 return reportAndExit(EVAL_PAGE); 894 895 br.doEndTag(writer); 896 if (!ref.isNull()) 897 write((String ) ref.getRef()); 898 899 localRelease(); 901 return EVAL_PAGE; 902 } 903 904 if (_dynamicOptions != null) { 907 if (_dynamicOptions instanceof Map) { 908 Map dynamicOptionsMap = (Map) _dynamicOptions; 909 Iterator keyIterator = dynamicOptionsMap.keySet().iterator(); 910 while (keyIterator.hasNext()) { 911 Object optionValue = keyIterator.next(); 912 String optionDisplay = null; 913 if (dynamicOptionsMap.get(optionValue) != null) { 914 optionDisplay = dynamicOptionsMap.get(optionValue).toString(); 915 } 916 917 addOption(req, optionValue.toString(), optionDisplay); 918 } 919 } 920 else if (_dynamicOptions instanceof Iterator) { 921 Iterator dynamicOptionsIterator = (Iterator) evaluateOptionsDataSource(); 922 while (dynamicOptionsIterator.hasNext()) { 923 Object o = dynamicOptionsIterator.next(); 924 if (o != null) { 925 String optionValue = o.toString(); 926 addOption(req, optionValue, optionValue); 927 } 928 } 929 } 930 } 931 932 addDatasourceIfNeeded(req); 934 addDefaultsIfNeeded(req); 935 if (_nullable && !isMultiple()) { 936 String txt = (_nullableOptionText != null) ? _nullableOptionText : ""; 937 addOption(req, NULL_VALUE, txt); 938 } 939 940 br.doEndTag(writer); 941 if (!ref.isNull()) 942 write((String ) ref.getRef()); 943 944 localRelease(); 946 return EVAL_PAGE; 947 } 948 949 952 protected void localRelease() 953 { 954 if (_repeater) 955 DataAccessProviderStack.removeDataAccessProvider(pageContext); 956 957 super.localRelease(); 958 _state.clear(); 959 960 _defaultSelections = null; 961 _formatters = null; 962 _match = null; 963 _saveBody = null; 964 _nullable = false; 965 _nullableOptionText = null; 966 _optionList = null; 967 968 _repIdx = 0; 969 _repeater = false; 970 _repCurItem = null; 971 _repCurStage = RepeatingStages.BEFORE; 972 _dynamicOptions = null; 973 _formatterError = false; 974 _optRb = null; 975 976 _order = DEFAULT_ORDER; 977 } 978 979 private String getErrorsFromBody() 980 { 981 final String END_TOKEN = "</span>"; 982 assert(_saveBody != null); 983 InternalStringBuilder body = new InternalStringBuilder(_saveBody.length()); 984 InternalStringBuilder error = new InternalStringBuilder(_saveBody.length()); 985 986 int len = _saveBody.length(); 988 int pos = 0; 989 while (pos < len) { 990 991 int start = _saveBody.indexOf("<span", pos); 993 if (start == -1) 994 break; 995 996 int end = _saveBody.indexOf(END_TOKEN); 998 if (end == -1) 999 break; 1000 1001 int realEnd = end + END_TOKEN.length() + 1; 1003 body.append(_saveBody.substring(pos, start)); 1004 error.append(_saveBody.substring(start, realEnd)); 1005 pos = realEnd; 1006 } 1007 1008 body.append(_saveBody.substring(pos, len)); 1010 _saveBody = body.toString(); 1011 1012 return error.toString(); 1014 } 1015 1016 1024 private boolean doRepeaterAfterBody() 1025 throws JspException  1026 { 1027 switch (_repCurStage.getValue()) { 1028 case RepeatingStages.INT_BEFORE: 1029 if (!moveNext()) 1030 return false; 1031 return doRepeaterAfterBody(); 1032 case RepeatingStages.INT_OPTION: 1033 assert (_repeaterIterator instanceof Iterator); 1034 while (_repeaterIterator.hasNext()) { 1035 _repCurItem = _repeaterIterator.next(); 1036 if (_repCurItem != null) { 1037 _optionList.add(_repCurItem); 1038 return true; 1039 } 1040 } 1041 if (!moveNext()) 1042 return false; 1043 return doRepeaterAfterBody(); 1044 1045 case RepeatingStages.INT_DEFAULT: 1046 case RepeatingStages.INT_DATASOURCE: 1047 case RepeatingStages.INT_NULL: 1048 assert (_repeaterIterator instanceof Iterator); 1049 while (_repeaterIterator.hasNext()) { 1050 _repCurItem = _repeaterIterator.next(); 1051 if (!_optionList.contains(_repCurItem)) { 1052 _optionList.add(_repCurItem); 1053 return true; 1054 } 1055 } 1056 if (!moveNext()) 1057 return false; 1058 return doRepeaterAfterBody(); 1059 } 1060 return false; 1061 } 1062 1063 1071 private boolean moveNext() 1072 throws JspException  1073 { 1074 _repIdx++; 1076 if (_repIdx == _order.length) 1077 return false; 1078 1079 _repCurStage = _order[_repIdx]; 1081 _repeaterIterator = null; 1082 1083 switch (_repCurStage.getValue()) { 1086 case RepeatingStages.INT_BEFORE: 1087 break; 1088 case RepeatingStages.INT_OPTION: 1089 if (!(_dynamicOptions instanceof Iterator)) { 1091 String s = Bundle.getString("Tags_OptionsDSIteratorError"); 1092 registerTagError(s, null); 1093 return false; 1094 } 1095 1096 assert(_dynamicOptions instanceof Iterator); 1097 _repeaterIterator = (Iterator) _dynamicOptions; 1098 break; 1099 1100 case RepeatingStages.INT_DEFAULT: 1101 if (_defaultSelections != null) 1102 _repeaterIterator = _defaultSelections.iterator(); 1103 break; 1104 case RepeatingStages.INT_DATASOURCE: 1105 if (_match != null) 1106 _repeaterIterator = Arrays.asList(_match).iterator(); 1107 break; 1108 case RepeatingStages.INT_NULL: 1109 if (_nullable) 1110 _repeaterIterator = new ArrayIterator(NULL_INSTANCE); 1111 break; 1112 } 1113 1114 return (_repeaterIterator != null) ? true : moveNext(); 1116 } 1117 1118 1122 private void buildMatch(Object val) 1123 { 1124 if (val != null) { 1126 if (val instanceof String ) { 1127 _match = new String []{(String ) val}; 1128 } 1129 else if (val instanceof String []) { 1130 String [] s = (String []) val; 1131 int cnt = 0; 1132 for (int i = 0; i < s.length; i++) { 1133 if (s[i] != null) 1134 cnt++; 1135 } 1136 if (cnt == s.length) 1137 _match = s; 1138 else { 1139 if (cnt > 0) { 1140 _match = new String [cnt]; 1141 cnt = 0; 1142 for (int i = 0; i < s.length; i++) { 1143 if (s[i] != null) { 1144 _match[cnt++] = s[i]; 1145 } 1146 } 1147 } 1148 } 1149 } 1150 else { 1151 Iterator matchIterator = null; 1152 matchIterator = IteratorFactory.createIterator(val); 1154 if (matchIterator == null) { 1155 matchIterator = IteratorFactory.EMPTY_ITERATOR; 1156 } 1157 1158 ArrayList matchList = new ArrayList(); 1159 while (matchIterator.hasNext()) { 1160 Object o = matchIterator.next(); 1161 if (o == null) 1162 continue; 1163 matchList.add(o); 1164 } 1165 1166 int size = matchList.size(); 1167 _match = new String [size]; 1168 for (int i = 0; i < size; i++) { 1169 assert (matchList.get(i) != null); 1170 assert (matchList.get(i).toString() != null); 1171 _match[i] = matchList.get(i).toString(); 1172 } 1173 } 1174 if (logger.isDebugEnabled()) { 1175 logger.debug("****** Select Matches ******"); 1176 if (_match != null) { 1177 for (int i = 0; i < _match.length; i++) { 1178 logger.debug(i + ": " + _match[i]); 1179 } 1180 } 1181 } 1182 } 1183 else { 1184 if (_nullable && !isMultiple()) { 1185 _match = new String []{NULL_VALUE}; 1186 } 1187 } 1188 } 1189 1190 private void addDefaultsIfNeeded(ServletRequest req) 1192 throws JspException  1193 { 1194 if (_defaultSelections != null) { 1195 Iterator iterator = _defaultSelections.iterator(); 1196 while (iterator.hasNext()) { 1197 Object selection = iterator.next(); 1198 if (!_optionList.contains(selection)) { 1199 addOption(req, selection.toString(), selection.toString()); 1200 } 1201 } 1202 } 1203 } 1204 1205 private boolean isMultiple() 1206 { 1207 return _state.multiple; 1208 } 1209 1210 private void addDatasourceIfNeeded(ServletRequest req) 1212 throws JspException  1213 { 1214 if (_match == null) 1215 return; 1216 1217 for (int i = 0; i < _match.length; i++) { 1218 if (!_optionList.contains(_match[i])) { 1219 if (!_match[i].equals(NULL_VALUE)) 1220 addOption(req, _match[i], _match[i]); 1221 } 1222 } 1223 } 1224 1225 private void addOption(ServletRequest req, String optionValue, String optionDisplay) 1226 throws JspException  1227 { 1228 assert(optionValue != null); 1229 assert(optionDisplay != null); 1230 1231 write("\n"); 1232 _optionState.clear(); 1233 _optionState.value = optionValue; 1234 _optionState.style = _state.style; 1235 _optionState.styleClass = _state.styleClass; 1236 1237 if (isMatched(optionValue)) { 1238 _optionState.selected = true; 1239 } 1240 1241 WriteRenderAppender writer = new WriteRenderAppender(pageContext); 1242 if (_optRb == null) 1243 _optRb = TagRenderingBase.Factory.getRendering(TagRenderingBase.OPTION_TAG, req); 1244 _optRb.doStartTag(writer, _optionState); 1245 1246 1247 if (optionDisplay != null) { 1248 write(formatText(optionDisplay)); 1249 } 1250 else { 1251 write("<"); 1252 write(optionValue); 1253 write(">"); 1254 } 1255 1256 _optRb.doEndTag(writer); 1257 1258 addOptionToList(optionValue); 1259 } 1260 1261 1265 public void addFormatter(FormatTag.Formatter formatter) 1266 { 1267 _formatters.add(formatter); 1268 } 1269 1270 1274 public void formatterHasError() 1275 { 1276 _formatterError = true; 1277 } 1278 1279 1281 public void addOptionToList(String value) 1282 { 1283 _optionList.add(value); 1284 } 1285 1286 1291 public String formatText(Object text) 1292 throws JspException  1293 { 1294 int cnt = _formatters.size(); 1295 for (int i = 0; i < cnt; i++) { 1296 FormatTag.Formatter currentFormatter = (FormatTag.Formatter) _formatters.get(i); 1297 try { 1298 text = currentFormatter.format(text); 1299 } 1300 catch (JspException e) { 1301 registerTagError(e.getMessage(), e); 1302 } 1303 } 1304 return text.toString(); 1305 } 1306 1307 1313 1314 1332 public void setAccessKey(char accessKey) 1333 { 1334 _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL, ACCESSKEY, Character.toString(accessKey)); 1335 } 1336 1337 1348 public void setTabindex(int tabindex) 1349 { 1350 _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL, TABINDEX, Integer.toString(tabindex)); 1351 } 1352} 1353 1354 | Popular Tags |