Link to home
Start Free TrialLog in
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

Avatar of CyanBlue
CyanBlue
Flag of United States of America image

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

Avatar of hallikpapa
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.
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.
ASKER CERTIFIED SOLUTION
Avatar of zzynx
zzynx
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
That's what I said in the previous comment, yes.
Yep pretty much.  Presuming backend is java but that apply to any other languages aswell.
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!

Good luck.
Thanx 4 axxepting