+1 to having *some* solution here.
Perhaps SortableModel should have support for Comparators
(which is implemented by Collators). One possible API would be:
public Map<String, Comparator> getComparators();
... so you could do:
Collator collator =
Collator.getInstance(FacesContext.getCurrentInstance().getViewRoot().getLocale());
model.getComparators().put("myField", collator);
This would require manual setup per field, though. But
I think it would solve the problem we have right now where
we don't know how to sort a column if the first entry
is null.
Another possibility is adding a protected hook:
protected Comparator getComparator(
String fieldName, Object sampleObject);
Manual setup again, but at least you could write one
class that had it turned on for all Strings.
And yet another way of doing this would be automatically using
Collator.getInstance() for Strings, or adding a flag to turn
it on - I'm not well-versed in the performance implications
of using Collator, and would want to know before turning this
on by default. And it's not obvious that you would always want it on -
I could imagine that some strings might want to be sorted
in a non-internationalized manner.
Ideas, preferences?
-- Adam
On 1/21/07, Martin Koci <[EMAIL PROTECTED]> wrote:
Hello,
I trying to use SortableModel instead my own implementation, but it has
one big issue - doesn't support Czech language.
We (here in the middle of Europe) have very special rules for sorting
words which cannot be done with simple:
value1.toString().compareTo(value2.toString())
Fortunately java has a build-in support with Collator:
Collator collator =
Collator.getInstance(FacesContext.getCurrentInstance().getViewRoot().getLocale());
collator.compare(value1, value2);
Should I create a JIRA issue?
Thanks,
Martin
For experts and czech native speakers :D
http://146.102.68.23/kizi/IKSy/kap12.htm