[
http://issues.apache.org/jira/browse/COCOON-1879?page=comments#action_12420112
]
Bruno Dumon commented on COCOON-1879:
-------------------------------------
Looks good.
I'd validate the value of the whitespace attribute so that it gives an error
when using an unsupported value (to protect against typos).
I'd also avoid doing string comparisons to check the type of whitespace
trimming (e..g trimming.equals("preserve")), since these are relatively
expensive (though for these short strings, it won't matter much).
Something that solves both problems, is the use of an enumeration class,
following the type-safe enumeration pattern, as described at e.g.
http://java.sun.com/developer/Books/shiftintojava/page1.html
Thus a class like:
public class Whitespace {
public static final Whitespace PRESERVE = new Whitespace("preserve");
public static final Whitespace TRIM_START = new Whitespace("trim-start");
private final String name;
private Whitespace(String name) {
this.name = name;
}
public String toString() {
return name;
}
}
and as described in the linked article, one can then simply use e.g. "trimming
== Whitespace.PRESERVE" to test the sort of trimming.
With this change, this patch will be ready to commit, so if you have SVN access
already, you can do that yourself.
Don't forget to mention the change in status.xml, and update the docs in Daisy:
http://cocoon.zones.apache.org/daisy/documentation/864/forms/widgets/481.html
> Make fd:field whitespace trimming behavior configurable
> -------------------------------------------------------
>
> Key: COCOON-1879
> URL: http://issues.apache.org/jira/browse/COCOON-1879
> Project: Cocoon
> Type: Improvement
> Components: Blocks: Forms
> Versions: 2.2-dev (Current SVN), 2.1.10-dev (current SVN)
> Reporter: Jason Johnston
> Attachments: COCOON-1879.diff
>
> Currently fd:field widgets always trim leading and trailing whitespace from
> the user's input. Sometimes this behavior is not desired, so it should be
> configurable.
> See this thread for discussion:
> http://marc.theaimsgroup.com/?t=114960231400008&r=1&w=2
> Patch forthcoming.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira