I just came across this myself and figured out the problem.
PHP retrieved the data from my database and even though the entry in
the database was boolean PHP (Because it is a loosely typed language)
returned the entry as a string with the value of "0". When this was
returned, Flex coerced this string value to a boolean. As "0" is a non
empty string, Flex coerced it to true (Which is what it should do for
any non-empty string).
The "Fix" is to coerce the value to an int at the PHP end. For example:
$myObject->booleanField = (int)$row['booleanField'];
Now, when the number 0 comes in, Flex correctly coerces it to false.
--- In [email protected], Manu Dhanda <[EMAIL PROTECTED]> wrote:
>
>
> Hii,
>
> I tried it the same way as suggested by Uber Nick. But the solution
din't
> worked until I made some changes in my database field types as well
as on my
> Flex VO class.
> Now I set this field as integer in db and Number in my VO class and
> receiving the values as Number.
>
> like below:
>
> vo.aircon = int(list[i].aircon);
>
> Now, flex can easily interpret a number other than ZERO as TRUE and
Numbers
> ZERO as FALSE.
>
> But I suppose, the culprit part remains with the WebORB implementation.
>
> Thanks for helping.
> Manu.
>
>
>
> jmfillman wrote:
> >
> > Manu,
> >
> > First thing I'd do is trace (list[i].aircon) or bind the
> > ArrayCollection to a dataGrid to see what is actually being returned.
> >
> > My suspicion is that you are getting the correct true and false data
> > in the result, but as Uber_Nick suggested, it's a string value, so
> > you'll need to add an if statement, like this:
> >
> > if (list[i].aircon == 'true') {
> > vo.aircon = true;
> > }
> > else if (list[i].aircon == 'false') {
> > vo.aircon = false;
> > }
> >
> > JF
> > --- In [email protected], Manu Dhanda <manuraj.dhanda@>
> > wrote:
> >>
> >>
> >> Hii..
> >>
> >> Anyone of you experts with a solution for my problem??
> >> Am really worried for this little boolean problem.
> >>
> >> Manu.
> >>
> >>
> >>
> >> Uber_Nick wrote:
> >> >
> >> > Manu,
> >> >
> >> > Note the following.
> >> > trace(Boolean('TRUE')); // returns true
> >> > trace(Boolean('FALSE')); // also returns true
> >> >
> >> > Flex is interpreting the result from your PHP call as a String.
> > Try
> >> > returning lower-case 'true' and 'false'. Also, try using:
> >> > list[i].aircon as Boolean
> >> > instead of:
> >> > Boolean(list[i].aircon)
> >> > The former will not always convert to true (but will return null
> > if it
> >> > can't convert). Lastly, if you can't make it work, just try this
> >> > workaround:
> >> > vo.aircon = (''+list[i].aircon).toLowerCase()=='true';
> >> >
> >> > -Nick Matelli
> >> > Amentra, Inc
> >> >
> >> > --- In [email protected], Manu Dhanda <manuraj.dhanda@>
> > wrote:
> >> >>
> >> >>
> >> >> Code for my Responder, where I am receiving the result:
> >> >> public function result(data:Object):void
> >> >> {
> >> >> //TODO: implement function
> >> >> var objList:ArrayCollection = new
> > ArrayCollection();
> >> >> var list:ArrayCollection = new ArrayCollection
> > (data.result as Array);
> >> >> var vo:FlatVO;
> >> >> for(var i:int=0; i<list.length; i++){
> >> >> vo = new FlatVO();
> >> >> vo.userId = int(list[i].userId);
> >> >> vo.aircon = Boolean(list[i].aircon);
> >> >> objList.addItem(vo);
> >> >> }
> >> >>
> >> >> In here, I supposed to get vo.aircon as boolean[values as
> > true/false for
> >> >> different rows/objects in FlatVO]. But, the strange thing is
> > that I am
> >> >> receiving all the values for my boolean type as TRUE only.
> >> >>
> >> >> I had verified on my server side PHP code, and it is returning
> > the
> >> >> corresponding values fine [as in TRUE and FALSE accordingly].
> >> >>
> >> >> I am using WebORB for PHP with Flex. and in there, I had
> > verified in the
> >> >> Services as well, that my service returning this object has the
> > right
> >> >> values. Then how come I am receiving all the values as TRUE, I
> > can not
> >> >> understand this.
> >> >>
> >> >> Any help will be great.
> >> >> Thanks.
> >> >>
> >> >> Igor Costa-2 wrote:
> >> >> >
> >> >> > If you paste a part of your code someone here in the list can
> >> > answer you
> >> >> > but
> >> >> > it's hard to get what you really need.
> >> >> >
> >> >> >
> >> >> > Regards
> >> >> > Igor
> >> >> >
> >> >> > On Tue, Jun 3, 2008 at 11:45 AM, Manu Dhanda <manuraj.dhanda@>
> >> >> > wrote:
> >> >> >
> >> >> >>
> >> >> >> Hii,
> >> >> >>
> >> >> >> In short, In Weborb Mgmt Services, I can see the object
> > having a
> >> > value of
> >> >> >> boolean type correctly.( that is it is returned correctly from
> >> > the db).
> >> >> >> But when I receive it on Flex side, all is returned as true.
> >> >> >>
> >> >> >> How should I resolve this?
> >> >> >>
> >> >> >> Appreciate your time.. to respond it.
> >> >> >>
> >> >> >> thanks.
> >> >> >>
> >> >> >> --
> >> >> >> View this message in context:
> >> >> >>
> >> > http://www.nabble.com/Flex-%2B-WebORB-for-PHP%2C-A-very-strage-
> > problem-tp17625304p17625304.html
> >> >> >> Sent from the FlexCoders mailing list archive at Nabble.com.
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >
> >> >> >
> >> >> >
> >> >> > --
> >> >> > ----------------------------
> >> >> > Igor Costa
> >> >> > www.igorcosta.com
> >> >> > www.igorcosta.org
> >> >> >
> >> >> >
> >> >>
> >> >> --
> >> >> View this message in context:
> >> > http://www.nabble.com/Flex-%2B-WebORB-for-PHP%2C-A-very-strange-
> > problem-tp17625304p17631029.html
> >> >> Sent from the FlexCoders mailing list archive at Nabble.com.
> >> >>
> >> >
> >> >
> >> >
> >> >
> >>
> >> --
> >> View this message in context: http://www.nabble.com/Flex-%2B-WebORB-
> > for-PHP%2C-A-very-strange-problem-tp17625304p17672147.html
> >> Sent from the FlexCoders mailing list archive at Nabble.com.
> >>
> >
> >
> >
> >
>
> --
> View this message in context:
http://www.nabble.com/Flex-%2B-WebORB-for-PHP%2C-A-very-strange-problem-tp17625304p17674628.html
> Sent from the FlexCoders mailing list archive at Nabble.com.
>