By Duncan Mills-Oracle on Apr 30, 2013
With every new release you can trawl through the release notes and fine some handy new features to play with, however, sometimes there is even more to discover hidden away.
One such feature, which I think is actually pretty exciting, has crept into the 18.104.22.168.0 release of JDeveloper / ADF. This is a new feature which adds case insensitive sorting to the table. Previously we have had to resort to tricks such as defining transient attributes where all attributes are converted to a particular case in order to create this transient attribute. It would then be used as the sortProperty on the <af:column> that houses the column that you wanted to sort in a case insensitive way. Not too difficult to do, but it means adding stuff to your model to satisfy a UI need. Now there is a cleaner way.
So to replace this technique, we now have a new property on <af:column> called sortStrength. This new property takes one of four values which allow you some degree of control as to how the sorting takes place. The resulting sorts are locale specific. This is probably best illustrated with a table:
|Identical (default)||This is the default value and reflects the traditional behavior where the sort is very sensitive. i.e AA != aa and aa != áá|
|Primary||Only the primary difference is observed i.e. the underlying letter. So a != b of course but AA == aa == áá == Äæ for the purposes of sort. You can think of this as the most promiscuous sort|
|Secondary||Secondary is still case insensitive. A secondary difference is something like an accented version of a character. So in this case AA == aa, however, aa != áá.|
Returns us to the world of case sensitivity, so AA != Aa != áá != ÁÁ. There are some subtle locale specific differences between Identical and Tertiary but for most purposes they will have the same effect
So you can see that for day-to-day case insensitive table sorting you should use the Primary or Secondary values depending on how you want to treat accented characters. If you are wondering where the weird Primary, Secondary, Tertiary thing came from, head over to the JavaDoc for the java.text.Collator class which is the mechanism underlying all of this.