• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Empty and null strings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
References: 
 >Empty and null strings (From: Miguel Arroz <email@hidden>)

  • Prev by Date: Re: Xcode 2.1 & WebObjects 5.3
  • Next by Date: Re: XCode Java Code Completion
  • Previous by thread: Empty and null strings
  • Next by thread: Re: Empty and null strings
  • Index(es):
    • Date
    • Thread