Re: Empty and null strings
Re: Empty and null strings
- Subject: Re: Empty and null strings
- From: LD <email@hidden>
- Date: Sat, 10 Sep 2005 22:52:31 +1000
Hi there,
On 10/09/2005, at 8:48 AM, Miguel Arroz wrote:
This must be a "most asked" question, but here goes...
I'm a little confused with empty and null strings, in what relates
to WOTextField component.
Why does a WOTextField value is null when there is no text?
Shouldn't it be an empty string? The empty string and null objects
are two distinct things for the model, right?
Interesting. If you set a key someString = "" then it's still changed
to null during takeValuesFromRequest.
// In any case, it's a fact of life with Java to test as follows:
if ( someString != null && someString.length() > 0 ) {
}
you could alternatively do something like the following (see below),
but that's a lot of hassle seeing as either way you can't escape the
above reality in your code (it's also good practice).
protected String someString;
<...>
public String someString() {
return someString;
}
public void setSomeString(String aValue) {
if ( aValue == null )
someString = "";
else
someString = aValue;
}
with regards,
--
LD
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden