You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by bu...@apache.org on 2005/02/22 13:30:12 UTC
DO NOT REPLY [Bug 33687] New: -
patch: XMLAdapter in Cocoon Forms only sets partial value when multiple characters() calls occur inside of one element
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=33687>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=33687
Summary: patch: XMLAdapter in Cocoon Forms only sets partial
value when multiple characters() calls occur inside of
one element
Product: Cocoon 2
Version: 2.1.6
Platform: All
OS/Version: All
Status: NEW
Keywords: PatchAvailable, RFC
Severity: major
Priority: P2
Component: CocoonForms
AssignedTo: dev@cocoon.apache.org
ReportedBy: asf-bugzilla@julien-oster.de
The XMLAdapter for XML Form binding handles one characters() event per XML
Element well, but when anything between the original SAX event source and the
XMLAdapter decides to split up the events, any subsequent characters() event is
just overwriting the former parts of the whole value.
This results in your form field values only being correct if there's exactly one
characters() event per element, and truncated otherwise. However, the SAX
specification allows this to occur.
This very small patch against the cocoon-2.1.6 release fixes this issue and
should be comprehensible without any further comments.
--- XMLAdapter.java.orig 2004-11-19 09:53:39.000000000 +0100
+++ XMLAdapter.java 2005-02-21 14:29:56.968946331 +0100
@@ -80,7 +80,8 @@
private Locale locale;
/** Is a <code>MultiValueField</code> handled? */
private boolean isMultiValueItem = false;
-
+ /** The current input string where XML characters get appended to, or
nullif there's no input inside the current element yet **/
+ private String currentinput;
/**
* Wrap a <code>Form</code> with an <code>XMLAdapter</code>
@@ -89,6 +90,8 @@
public XMLAdapter(Widget widget) {
this.widget = widget;
this.locale = Locale.US;
+
+ this.currentinput = null;
}
/**
@@ -175,6 +178,8 @@
*/
public void endElement(String uri, String loc, String raw)
throws SAXException {
+ currentinput = null;
+
if (this.currentWidget == null)
throw new SAXException("Wrong state");
@@ -208,7 +213,15 @@
*/
public void characters(char ch[], int start, int len)
throws SAXException {
- String input = new String(ch, start, len);
+ String input;
+
+ if (currentinput != null) {
+ input = currentinput + new String(ch, start, len);
+ } else {
+ input = new String(ch, start, len);
+ currentinput = input;
+ }
+
if ("".equals(input.trim()))
return;
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.