Avatar of hallikpapa
hallikpapa
 asked on

Implicit cast of int to boolean in VO

I am returning a UseraccountVO, and it contains an array of MappedusernameVO(s)

The property "allowed" in every Mappedusername comes into flex as either a 1 or 0. I want flex to convert it to true or false, as they are used for checkboxes.

The VO is setting everything to true. How can I setup the VO so it will convert 0's to false, and 1's to true?
package com.model.vo
{
	[RemoteClass(alias="com.model.vo.UseraccountVO")]
	
	[Bindable]
	public class UseraccountVO
	{
		[ArrayElementType("com.model.vo.MappedusernameVO")]
		public var Mappedusernames	:Array = new Array();
 
                public var id:int = 0;
                public var userName:String = '';
        }
}
 
///
///
///
package com.model.vo
{
	[RemoteClass(alias="com.model.vo.MappedusernameVO")]
	
	[Bindable]
	public class MappedusernameVO
	{
		
		public var userID			:int = 0;
		public var servicesID		:int = 0;
		public var userName			:String = "";
		public var allowed			:Boolean = false;
 
 
 
	}
}

Open in new window

Adobe FlashApache Flex

Avatar of undefined
Last Comment
zzynx

8/22/2022 - Mon
CyanBlue

I don't know if I am understanding you correctly or not, but what about this???

BTW, what is VO???

CyanBlue
var val:int;
var bool:Boolean;
 
val = 1;
bool = Boolean(val);
trace(val + " : " + bool);	// 1 : true
 
val = 0;
bool = Boolean(val);
trace(val + " : " + bool);	// 0 : false

Open in new window

hallikpapa

ASKER
I am sorry. VO stands for Value Object. Immediately when the data is received, it is coerced into the objects I posted above. I tried setting up a constructor that goes

allowed = Boolean(allowed);

But that didn't seem to work unless I did it incorrectly.
hallikpapa

ASKER
I should add, they all come back built already, and the only coercion I do into the value objects is here:

userForm.user = UseraccountVO(note.getBody());

So I believe even if there is a constructor in the Mappedusername, it isn't being called.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
ASKER CERTIFIED SOLUTION
zzynx

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Jones911

What the object is in the back end is what it will be in flex.  Is it 1 or 0?  send it as true/false from the server.
zzynx

That's what I said in the previous comment, yes.
Jones911

Yep pretty much.  Presuming backend is java but that apply to any other languages aswell.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
hallikpapa

ASKER
Yeah that was my first answer, but the guy who did the backend said just handle it on the flex side. I told him I veto that on the grounds it's stupid, but he was like can you see if you can, so I thought I would at least ask. :)

Anyways, enough of that, thanks guys!

zzynx

Good luck.
Thanx 4 axxepting