Matt Raible wrote:
Will this work without any additional changes?  Where is the
NumberFormatter created/implemented?

Yes, no additional changes needed. The NumberFormat is generated implicitly by the java.text.MessageFormat "form" created in SmartListHelper.getPageNavigationBar(...).


The MessageFormat class allows you to specify how a given argument is formatted. At present, "form" is constructed with a String that contains "page={0}".

In SmartListHelper.getPageNavigationBar(...), this "{0}" is replaced with the current page number, like this:

  Object[] v = {new Integer( i )};
  msg += "<a href=\"" + form.format( v ) + "\">" + i + "</a>";

The default behaviour of MessageFormat is to format Integers with a NumberFormat created with:

NumberFormat.getInstance(getLocale())

A NumberFormat object generated using my Locale formats Integers with a "," every three digits, e.g.

      123
    1,123
1,123,123

This is what caused the problem with large numbers of paged lists.

Fortunately, MessageFormat allows a custom NumberFormat object to be created, to use instead of the current Locale's. It does this by specifying keywords and format strings in the String you construct the MessageFormat object with. See the MessageFormat javadoc for exact details on how this works.

I replaced "page={0}" with "page="{0,number,#}", which builds a NumberFormat object (the "number" part) that formats the value as a plain number (the "#" part).

Cheers,

-Joe

--
[ Joe Holmberg | +44 1273 234293 | http://www.runtime-collective.com ]
[    Developer | +44 7909 784342 | Runtime Collective: Web Engineers ]



-------------------------------------------------------
This SF.NET email is sponsored by: eBay
Great deals on office technology -- on eBay now! Click here:
http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5
_______________________________________________
displaytag-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/displaytag-devel

Reply via email to