Discussion:
decimal . or , interchangeable
Ondřej Čada
2012-04-26 15:13:36 UTC
Permalink
Hello again,

the client want me to change a pretty old and pretty big WO application so that both '.' and ',' work interchangeably for a decimal point on input, in all fields of all forms.

I know a number of ways to do that for a specific field, but before I dive into that, isn't there a way to say globally for an entire WO application: "Hey, whenever and wherever you are converting a string to a number, consider '.' and ',' equal"? That would help a lot.

I went through the NSNumberFormatter API, but found nothing :(

Thanks and all the best,
---
Ondra Čada
OCSoftware: ***@ocs.cz http://www.ocs.cz
private ***@ocs.cz http://www.ocs.cz/oc
Chuck Hill
2012-04-26 19:05:34 UTC
Permalink
I think you will need a custom NSTimestampFormatter subclass for this.


Chuck
Post by Ondřej Čada
Hello again,
the client want me to change a pretty old and pretty big WO application so that both '.' and ',' work interchangeably for a decimal point on input, in all fields of all forms.
I know a number of ways to do that for a specific field, but before I dive into that, isn't there a way to say globally for an entire WO application: "Hey, whenever and wherever you are converting a string to a number, consider '.' and ',' equal"? That would help a lot.
I went through the NSNumberFormatter API, but found nothing :(
Thanks and all the best,
---
Ondra Čada
_______________________________________________
WebObjects-dev mailing list
http://www.omnigroup.com/mailman/listinfo/webobjects-dev
--
Chuck Hill Senior Consultant / VP Development

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/gvc/practical_webobjects
Ondřej Čada
2012-04-26 22:39:18 UTC
Permalink
Chuck,

thanks a lot!
Post by Chuck Hill
I think you will need a custom NSTimestampFormatter subclass for this.
I suppose you meant an NSNumberFormatter subclass, right? Or am I missing some fine point there?

Is there a way to "install" such an object globally to be used for all numeric form fields, or do I have to go through all forms and all fields and explicitly fill something like 'formatter="$application.myFormatter"' to each of them? That's what I'd like to get rid of -- if possible.

Thanks again,
OC
Post by Chuck Hill
Post by Ondřej Čada
Hello again,
the client want me to change a pretty old and pretty big WO application so that both '.' and ',' work interchangeably for a decimal point on input, in all fields of all forms.
I know a number of ways to do that for a specific field, but before I dive into that, isn't there a way to say globally for an entire WO application: "Hey, whenever and wherever you are converting a string to a number, consider '.' and ',' equal"? That would help a lot.
I went through the NSNumberFormatter API, but found nothing :(
Thanks and all the best,
---
Ondra Čada
Chuck Hill
2012-04-26 22:53:59 UTC
Permalink
Hi Ondra,
Post by Ondřej Čada
Chuck,
thanks a lot!
Post by Chuck Hill
I think you will need a custom NSTimestampFormatter subclass for this.
I suppose you meant an NSNumberFormatter subclass, right? Or am I missing some fine point there?
Yes, you are correct. You can probably guess which one I have been looking at lately. :-)
Post by Ondřej Čada
Is there a way to "install" such an object globally to be used for all numeric form fields, or do I have to go through all forms and all fields and explicitly fill something like 'formatter="$application.myFormatter"' to each of them? That's what I'd like to get rid of -- if possible.
I think the only way would be to make your own NSNumberFormatter in your own com.webobjects.foundation package and get it to load first on the classpath (Wonder does this for ERXExtensions).

Also, formatters are NOT threadsafe so having them shared from the application instance will lead to problems in times of high concurrency. They should be cached on the session or lower.


Chuck
Post by Ondřej Čada
Post by Chuck Hill
Post by Ondřej Čada
Hello again,
the client want me to change a pretty old and pretty big WO application so that both '.' and ',' work interchangeably for a decimal point on input, in all fields of all forms.
I know a number of ways to do that for a specific field, but before I dive into that, isn't there a way to say globally for an entire WO application: "Hey, whenever and wherever you are converting a string to a number, consider '.' and ',' equal"? That would help a lot.
I went through the NSNumberFormatter API, but found nothing :(
Thanks and all the best,
---
Ondra Čada
_______________________________________________
WebObjects-dev mailing list
http://www.omnigroup.com/mailman/listinfo/webobjects-dev
--
Chuck Hill Senior Consultant / VP Development

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/gvc/practical_webobjects
Loading...