On Apr 18, 2006, at 10:58 AM, WebObjects wrote:
Chuck/Ken/All,
Awesome recommendations. I realize that soon to follow will be
arguments
that exceptions should not be used as part of a designed flow control
I'd be happy to debate them in this situation. And it is not so much
catching exceptions for flow control, as passing them as a parameter:
public void validationFailedWithException(Throwable t,
Object value,
String keyPath)
Called when an Enterprise Object or formatter failed validation
during an assignment. The default implementation ignores the error.
Subclassers can override to record the error and possibly return a
different page for the current action
A different kettle O fish, IMHO.
- but
before they hit I'd like to say thanks, this is the solution I needed.
Glad to hear that it helped.
Chuck
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/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/archive%40mail-archive.com
This email sent to [email protected]