Tim, a colleague and I are trying to create a patch to address STS-322, and
we're running into an impasse. After looking into the various places we could
put the Formatter-invoking code, we decided that UrlBuilder was the natural
place. Our resulting first go at it is as follows:
public void addParameter(String name, Object... values) {
[...SNIP...]
for (Object v : values) {
FormatterFactory ff = null;
Formatter<Object> f = null;
String val = null;
Locale l = null;
ff = StripesFilter.getConfiguration().getFormatterFactory();
f = ff.getFormatter( v.getClass(), null, null, null );
if (f == null)
val = v.toString();
else
val = f.format( v );
// Figure out whether we already have params or not
if (!this.seenQuestionMark) {
this.url.append('?');
this.seenQuestionMark = true;
}
else {
this.url.append(this.parameterSeparator);
}
this.url.append(name);
this.url.append('=');
if (v != null) {
this.url.append( URLEncoder.encode(val,
"UTF-8") );
}
}
[...SNIP...]
}
I realize that this approach might need some tweaking, but we didn't get far
enough to make those tweaks. We found that, unfortunately for us, some objects
(like Long) have a default formatter that require the specification of a
Locale. We couldn't find a terribly convenient way to get a Locale into the
UrlBuilder, so we considered creating a thread-scoped Registry with a static
interface that is initialized per-request by the StripesFilter, then invoking
that from UrlBuilder to get the Locale. But then we thought that you might
have some compelling reasons why this shouldn't be done, and analysis paralysis
lead us to ask you directly before proceeding. Is this Registry for the
request a good idea, or would it cause problems that we're not seeing right
now?
How do you think we should proceed?
BD aka RJ
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com -------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development