• 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: Internal Data Type for BOOL
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Internal Data Type for BOOL


  • Subject: Re: Internal Data Type for BOOL
  • From: Pierre Frisch <email@hidden>
  • Date: Tue, 3 Jun 2003 21:00:07 -0700

There is a much easier solution using custom attributes You can get EOF to map directly from a String to a Boolean. Have a look at:

http://wodev.spearway.com/cgi-bin/WebObjects/WODev.woa/wa/ Main?wikiPage=BooleanModeling

Here is how I do it. I define the column as a Character Varying of 5 so that I can store "true" or "false". In EOModeler I define the Internal Data Type as custom the class as java.lang.Boolean, the factory method as valueOf and the Conversion method as toString and the init argument as NSString?. This works well even if it waste a little space in the database.

To make it easier to use you should define it as a prototype.

Woks with all databases, it does not rely on any implementation from the PlugIn and no accessor method to write. Works with EOGenerator too.

Pierre

On Tuesday, June 3, 2003, at 06:57  PM, Art Isbell wrote:

Different databases handle boolean datatypes in different ways, some more seamlessly than others. But all databases handle integer datatypes seamlessly, so making booleans integers should work across all databases.

After struggling somewhat with boolean data, I finally decided to adopt someone's suggestion on how to store booleans as integers. Basically, model booleans as integers in your eomodel. Name the boolean attribute with something like an "Int" suffix - e.g., isActiveInt. EOModeler's generated Java class file will contain isActiveInt() and setIsActiveInt() accessors. Add 2 more accessors that you will actually use in your WO apps including in WO component bindings:

    public boolean isActive() {
        Number isActive = isActiveInt();
        return ((isActive != null) && (isActive.intValue() == 1));
    }

    public void setIsActive(boolean aFlag) {
        setIsActiveInt(new Integer(aFlag ? 1 : 0));
    }

Aloha,
Art
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Internal Data Type for BOOL (From: Art Isbell <email@hidden>)

  • Prev by Date: webobjects5.2 and 3 dev books
  • Next by Date: Re: From OpenBase To MSSQLServer2000 (EOModeller)
  • Previous by thread: Re: Internal Data Type for BOOL
  • Next by thread: Applets working with WebObjects 5.2
  • Index(es):
    • Date
    • Thread