I do run across this exception when using this more globalized formatting
solution...

[2006-04-18 11:09:47 PDT] <WorkerThread2> java.lang.ClassCastException
    at 
com.webobjects.appserver._private.WOFormatterRepository.formatterForComponen
t(WOFormatterRepository.java:102)
    at 
com.webobjects.appserver._private.WOTextField.takeValuesFromRequest(WOTextFi
eld.java:55)

Is the returned type " NSTimestampFormatter" not compatible with the
expected formatter?

TextField5: WOTextField {
    value = newDonor.dtDob;
    dateformat = application.dateFormatter;
}

-Thx, Bill


on 4/18/06 10:53, Ken Anderson at [EMAIL PROTECTED] wrote:

> If you have users in multiple time zones, you could put the shared
> formatter in the session instead (same easy access), and then have it
> formatted to the user's timezone.
> 
> Ken
> 
> On Apr 18, 2006, at 1:46 PM, Chuck Hill wrote:
> 
>> I won't claim there is one best way.  Here is how I have been
>> handling these.  First off, stop using dateFormat/numberFormat.
>> They are easy to use, but as you have seen, no help at all in
>> validating input.  They are OK for output.  So, what to use
>> instead?  There is a formatter binding also available and I find
>> that works much better.  You will then be able to catch the
>> exception in your page (in validationFailedWithException I believe)
>> and handle it.
>> 
>> In order to make these easier to use, I usually declare them at the
>> application level using one of many variants of this:
>> 
>> protected static final NSTimestampFormatter dateFormatter = new
>> NSTimestampFormatter("%m/%d/%y");
>> 
>> public NSTimestampFormatter dateFormatter() {
>>     return Application.dateFormatter;
>> }
>> 
>> This makes it easy to bind as in:
>> 
>>> TextField5: WOTextField {
>>>     dateformat = application.dateFormat;
>>>     value = newDonor.dtDob;
>>> }
>> 
>> 
>> HTH
>> Chuck
>> 
>> 
>> 
>> On Apr 18, 2006, at 8:55 AM, WebObjects wrote:
>> 
>>> There's always an easier and better way, so why not ask? (right?)
>>> 
>>> I have a field in my form for collecting someone's date-of-birth.
>>> The value
>>> will store as an NSTimestamp in the dbase.
>>> 
>>>     public void setDtDob(NSTimestamp value) {
>>>         takeStoredValueForKey(value, "dtDob");
>>>     }
>>> 
>>> Q:  What is the best way to validate the users input, or get it to
>>> conform
>>> to what NSTimestamp will accept for a valid date format?
>>> 
>>> I have the field formatted like so:
>>> 
>>> TextField5: WOTextField {
>>>     dateformat = "%m/%d/%y";
>>>     value = newDonor.dtDob;
>>> }
>>> 
>>> ...however, this does nothing to protect me from a user who
>>> insists in
>>> typing gobbly-goop into the field.  I suppose a series of dropdown
>>> elements
>>> could help enforce input, but I'd rather use a way of catching the
>>> exception
>>> (here is the exception when user-input cannot be parsed):
>>> 
>>> [2006-04-18 08:19:52 PDT] <WorkerThread12> Validation failed on an
>>> object
>>> [java.lang.String] with keypath = newDonor.dtDob and exception:
>>> Format.parseObject(String) failed
>>> 
>>> Does anyone have a good method written for testing the String in a
>>> field
>>> against a formatting (ie. "%m/%d/%y") ?
>>> 
>>> TIA,
>>> -Bill
>>> 
>>> 
>>>  _______________________________________________
>>> Do not post admin requests to the list. They will be ignored.
>>> Webobjects-dev mailing list      ([email protected])
>>> Help/Unsubscribe/Update your Subscription:
>>> http://lists.apple.com/mailman/options/webobjects-dev/chill%
>>> 40global-village.net
>>> 
>>> This email sent to [EMAIL PROTECTED]
>> 
>> -- 
>> Coming in late 2006 - an introduction to web applications using
>> WebObjects and Xcode     http://www.global-village.net/wointro
>> 
>> 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/products/
>> practical_webobjects
>> 
>> 
>> 
>> 
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Webobjects-dev mailing list      ([email protected])
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/webobjects-dev/lists%
>> 40anderhome.com
>> 
>> This email sent to [EMAIL PROTECTED]
> 


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to