cvs commit: jakarta-struts/src/share/org/apache/struts/taglib/html OptionsTag.java
craigmcc02/03/15 20:02:07 Modified:doc/userGuide struts-html.xml src/share/org/apache/struts/taglib/html OptionsTag.java Log: Add a filter attribute to the html:options tag so that you can turn off filtering on option labels. Defaults to true for consistency with the previous behavior. PR: Bugzilla #6345 Submitted by: Dave Terrian dterrian at logiclink.com Revision ChangesPath 1.4 +11 -0 jakarta-struts/doc/userGuide/struts-html.xml Index: struts-html.xml === RCS file: /home/cvs/jakarta-struts/doc/userGuide/struts-html.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- struts-html.xml 3 Mar 2002 03:31:13 - 1.3 +++ struts-html.xml 16 Mar 2002 04:02:07 - 1.4 @@ -3494,6 +3494,17 @@ /attribute attribute +namefilter/name +requiredfalse/required +rtexprvaluetrue/rtexprvalue +info +Set to codefalse/code if you do NOT want the option labels +filtered for sensitive characters in HTML. By default, such +values are filtered. +/info +/attribute + +attribute namelabelName/name requiredfalse/required rtexprvaluetrue/rtexprvalue 1.16 +20 -1 jakarta-struts/src/share/org/apache/struts/taglib/html/OptionsTag.java Index: OptionsTag.java === RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/OptionsTag.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- OptionsTag.java 12 Mar 2002 05:46:08 - 1.15 +++ OptionsTag.java 16 Mar 2002 04:02:07 - 1.16 @@ -111,6 +111,20 @@ /** + * Should the label values be filtered for HTML sensitive characters? + */ +protected boolean filter = true; + +public boolean getFilter() { +return filter; +} + +public void setFilter(boolean filter) { +this.filter = filter; +} + + +/** * The name of the bean containing the labels collection. */ protected String labelName = null; @@ -324,6 +338,7 @@ super.release(); collection = null; +filter = true; labelName = null; labelProperty = null; name = null; @@ -365,7 +380,11 @@ sb.append(\); } sb.append(); -sb.append(ResponseUtils.filter(label)); +if (filter) { +sb.append(ResponseUtils.filter(label)); +} else { +sb.append(label); +} sb.append(/option\r\n); } -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
cvs commit: jakarta-struts/src/share/org/apache/struts/taglib/html OptionsTag.java
craigmcc02/03/15 20:02:50 Modified:doc Tag: STRUTS_1_0_BRANCH struts-html.xml src/share/org/apache/struts/taglib/html Tag: STRUTS_1_0_BRANCH OptionsTag.java Log: Port new filter attribute on html:options to the 1.0.x branch. PR: Bugzilla #6345 Submitted by: Dave Terrian dterrian at logiclink.com Revision ChangesPath No revision No revision 1.11.2.10 +11 -0 jakarta-struts/doc/Attic/struts-html.xml Index: struts-html.xml === RCS file: /home/cvs/jakarta-struts/doc/Attic/struts-html.xml,v retrieving revision 1.11.2.9 retrieving revision 1.11.2.10 diff -u -r1.11.2.9 -r1.11.2.10 --- struts-html.xml 6 Feb 2002 05:04:05 - 1.11.2.9 +++ struts-html.xml 16 Mar 2002 04:02:49 - 1.11.2.10 @@ -3023,6 +3023,17 @@ /attribute attribute +namefilter/name +requiredfalse/required +rtexprvaluetrue/rtexprvalue +info +Set to codefalse/code if you do NOT want the option labels +filtered for sensitive characters in HTML. By default, such +values are filtered. +/info +/attribute + +attribute namelabelName/name requiredfalse/required rtexprvaluetrue/rtexprvalue No revision No revision 1.7.2.8 +20 -1 jakarta-struts/src/share/org/apache/struts/taglib/html/OptionsTag.java Index: OptionsTag.java === RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/OptionsTag.java,v retrieving revision 1.7.2.7 retrieving revision 1.7.2.8 diff -u -r1.7.2.7 -r1.7.2.8 --- OptionsTag.java 12 Mar 2002 05:46:51 - 1.7.2.7 +++ OptionsTag.java 16 Mar 2002 04:02:50 - 1.7.2.8 @@ -111,6 +111,20 @@ /** + * Should the label values be filtered for HTML sensitive characters? + */ +protected boolean filter = true; + +public boolean getFilter() { +return filter; +} + +public void setFilter(boolean filter) { +this.filter = filter; +} + + +/** * The name of the bean containing the labels collection. */ protected String labelName = null; @@ -324,6 +338,7 @@ super.release(); collection = null; +filter = true; labelName = null; labelProperty = null; name = null; @@ -365,7 +380,11 @@ sb.append(\); } sb.append(); -sb.append(ResponseUtils.filter(label)); +if (filter) { +sb.append(ResponseUtils.filter(label)); +} else { +sb.append(label); +} sb.append(/option\r\n); } -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
cvs commit: jakarta-struts/src/share/org/apache/struts/taglib/html OptionsTag.java
craigmcc02/03/11 21:46:08 Modified:src/share/org/apache/struts/taglib/html OptionsTag.java Log: Properly deal with null values in either the labels or values array, by converting them to zero-length strings instead of throwing NPEs. PR: Bugzilla #6439 Submitted by: Wilhelm Fitzpatrick rafial at well.com Revision ChangesPath 1.15 +12 -3 jakarta-struts/src/share/org/apache/struts/taglib/html/OptionsTag.java Index: OptionsTag.java === RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/OptionsTag.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- OptionsTag.java 5 Oct 2001 05:07:47 - 1.14 +++ OptionsTag.java 12 Mar 2002 05:46:08 - 1.15 @@ -290,10 +290,19 @@ // Render the options tags for each element of the values coll. while (valuesIterator.hasNext()) { - String value = valuesIterator.next().toString(); + Object valueObject = valuesIterator.next(); + if (valueObject == null) { + valueObject = ; + } + String value = valueObject.toString(); String label = value; - if (labelsIterator.hasNext()) - label = labelsIterator.next().toString(); + if (labelsIterator.hasNext()) { + Object labelObject = labelsIterator.next(); + if (labelObject == null) { + labelObject = ; + } + label = labelObject.toString(); + } addOption(sb, value, label, selectTag.isMatched(value)); } -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
cvs commit: jakarta-struts/src/share/org/apache/struts/taglib/html OptionsTag.java
craigmcc02/03/11 21:46:52 Modified:src/share/org/apache/struts/taglib/html Tag: STRUTS_1_0_BRANCH OptionsTag.java Log: Port the fix for handling null values in the labels and values collections. PR: Bugzilla #6439 Submitted by: Wilhelm Fitzpatrick rafial at well.com Revision ChangesPath No revision No revision 1.7.2.7 +12 -3 jakarta-struts/src/share/org/apache/struts/taglib/html/OptionsTag.java Index: OptionsTag.java === RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/OptionsTag.java,v retrieving revision 1.7.2.6 retrieving revision 1.7.2.7 diff -u -r1.7.2.6 -r1.7.2.7 --- OptionsTag.java 5 Oct 2001 05:05:48 - 1.7.2.6 +++ OptionsTag.java 12 Mar 2002 05:46:51 - 1.7.2.7 @@ -290,10 +290,19 @@ // Render the options tags for each element of the values coll. while (valuesIterator.hasNext()) { - String value = valuesIterator.next().toString(); + Object valueObject = valuesIterator.next(); + if (valueObject == null) { + valueObject = ; + } + String value = valueObject.toString(); String label = value; - if (labelsIterator.hasNext()) - label = labelsIterator.next().toString(); + if (labelsIterator.hasNext()) { + Object labelObject = labelsIterator.next(); + if (labelObject == null) { + labelObject = ; + } + label = labelObject.toString(); + } addOption(sb, value, label, selectTag.isMatched(value)); } -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
cvs commit: jakarta-struts/src/share/org/apache/struts/taglib/html OptionsTag.java
craigmcc01/10/03 20:44:17 Modified:src/share/org/apache/struts/taglib/html Tag: STRUTS_1_0_BRANCH OptionsTag.java Log: If the property specified by the property attribute returns null, throw an error message that indicates what the real problem is, rather than causing an NPE. PR: Bugzilla #3161 Submitted by: [EMAIL PROTECTED] Revision ChangesPath No revision No revision 1.7.2.5 +3 -0 jakarta-struts/src/share/org/apache/struts/taglib/html/OptionsTag.java Index: OptionsTag.java === RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/OptionsTag.java,v retrieving revision 1.7.2.4 retrieving revision 1.7.2.5 diff -u -r1.7.2.4 -r1.7.2.5 --- OptionsTag.java 2001/06/10 03:51:41 1.7.2.4 +++ OptionsTag.java 2001/10/04 03:44:17 1.7.2.5 @@ -348,6 +348,9 @@ if (property != null) { try { collection = PropertyUtils.getProperty(bean, property); +if (collection == null) +throw new JspException +(messages.getMessage(getter.property, property)); } catch (IllegalAccessException e) { throw new JspException (messages.getMessage(getter.access, property, name));
cvs commit: jakarta-struts/src/share/org/apache/struts/taglib/html OptionsTag.java
craigmcc01/10/03 20:45:09 Modified:src/share/org/apache/struts/taglib/html OptionsTag.java Log: Port fix to Bugzilla #3161 to HEAD branch. Revision ChangesPath 1.13 +3 -0 jakarta-struts/src/share/org/apache/struts/taglib/html/OptionsTag.java Index: OptionsTag.java === RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/OptionsTag.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- OptionsTag.java 2001/07/16 00:44:55 1.12 +++ OptionsTag.java 2001/10/04 03:45:09 1.13 @@ -348,6 +348,9 @@ if (property != null) { try { collection = PropertyUtils.getProperty(bean, property); +if (collection == null) +throw new JspException +(messages.getMessage(getter.property, property)); } catch (IllegalAccessException e) { throw new JspException (messages.getMessage(getter.access, property, name));
cvs commit: jakarta-struts/src/share/org/apache/struts/taglib/html OptionsTag.java
craigmcc01/06/01 13:14:47 Modified:src/share/org/apache/struts/taglib/html Tag: STRUTS_1_0_BRANCH OptionsTag.java Log: Report the correct property name if the labelProperty attribute is incorrect on an html:options tag. PR: Bugzilla #1936 Submitted by: Zane Rockenbaugh [EMAIL PROTECTED] Revision ChangesPath No revision No revision 1.7.2.2 +25 -3 jakarta-struts/src/share/org/apache/struts/taglib/html/OptionsTag.java Index: OptionsTag.java === RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/OptionsTag.java,v retrieving revision 1.7.2.1 retrieving revision 1.7.2.2 diff -u -r1.7.2.1 -r1.7.2.2 --- OptionsTag.java 2001/05/20 21:20:10 1.7.2.1 +++ OptionsTag.java 2001/06/01 20:14:46 1.7.2.2 @@ -193,13 +193,31 @@ if (collection != null) { Iterator collIterator = getIterator(collection, null); while (collIterator.hasNext()) { + Object bean = collIterator.next(); Object value = null; Object label = null;; + try { value = PropertyUtils.getProperty(bean, property); if (value == null) value = ; +} catch (IllegalAccessException e) { +throw new JspException +(messages.getMessage(getter.access, + property, collection)); +} catch (InvocationTargetException e) { +Throwable t = e.getTargetException(); +throw new JspException +(messages.getMessage(getter.result, + property, t.toString())); +} catch (NoSuchMethodException e) { +throw new JspException +(messages.getMessage(getter.method, + property, collection)); +} + +try { if (labelProperty != null) label = PropertyUtils.getProperty(bean, labelProperty); @@ -210,21 +228,25 @@ } catch (IllegalAccessException e) { throw new JspException (messages.getMessage(getter.access, - property, collection)); + labelProperty, collection)); } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); throw new JspException (messages.getMessage(getter.result, - property, t.toString())); + labelProperty, t.toString())); } catch (NoSuchMethodException e) { throw new JspException (messages.getMessage(getter.method, - property, collection)); + labelProperty, collection)); } + + String stringValue = value.toString(); addOption(sb, stringValue, label.toString(), selectTag.isMatched(stringValue)); + } + } // Otherwise, use the separate iterators mode to render options
Re: cvs commit: jakarta-struts/src/share/org/apache/struts/taglib/html OptionsTag.java
I looked into that when doing the patch. Because these calls are all protected by hasNext() checks, IMHO you are guaranteed that there really will be a next element. Therefore, the only way you can get a null back is if your collection itself contains a null element. This is legal in the general case of Java development, but it's hard to say what a null value should mean in the context of an html:options tag. What do you think the behavior should be in that case? As i said before. I always have the Collection filled in but.. One thing should it not do: a null string in the html if it finds a null it should do insert an empty in the html. johan
cvs commit: jakarta-struts/src/share/org/apache/struts/taglib/html OptionsTag.java
craigmcc01/05/20 14:21:23 Modified:src/share/org/apache/struts/taglib/html OptionsTag.java Log: Port fix for Bugzilla #1825 to the HEAD branch. Revision ChangesPath 1.8 +2 -2 jakarta-struts/src/share/org/apache/struts/taglib/html/OptionsTag.java Index: OptionsTag.java === RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/OptionsTag.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- OptionsTag.java 2001/04/29 00:38:04 1.7 +++ OptionsTag.java 2001/05/20 21:21:23 1.8 @@ -240,10 +240,10 @@ // Render the options tags for each element of the values coll. while (valuesIterator.hasNext()) { - String value = (String) valuesIterator.next(); + String value = valuesIterator.next().toString(); String label = value; if (labelsIterator.hasNext()) - label = (String) labelsIterator.next(); + label = labelsIterator.next().toString(); addOption(sb, value, label, selectTag.isMatched(value)); }
cvs commit: jakarta-struts/src/share/org/apache/struts/taglib/html OptionsTag.java
craigmcc01/04/19 14:20:36 Modified:src/share/org/apache/struts/taglib/html OptionsTag.java Log: Filter the label text of generated options for characters that are sensitive in HTML. PR: Bugzilla #1177 Submitted by: [EMAIL PROTECTED] Revision ChangesPath 1.6 +1 -1 jakarta-struts/src/share/org/apache/struts/taglib/html/OptionsTag.java Index: OptionsTag.java === RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/OptionsTag.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- OptionsTag.java 2001/04/18 23:51:31 1.5 +++ OptionsTag.java 2001/04/19 21:20:34 1.6 @@ -295,7 +295,7 @@ if (matched) sb.append(" selected"); sb.append(""); -sb.append(label); +sb.append(ResponseUtils.filter(label)); sb.append("/option\r\n"); }