Problem to cretate dynamic radio button in flex.
- by nemade-vipin
hi friends,
I am creating the flex ARI application in which I am accessing the webservice method this method is returning me a childList.I am accessing it in my flex appliction using the Array object in my action script code.Now I want to cretate one flex page in which I get child list with radio button.I have done it using Arraycollection in which i put all the child name.Now I am getting each child name in mxml using the Repeater component in mxml.But I have problem is that I am getting the only list of child name.I also want to get child id for to set value for each radio button.
how can I refer same childname and it's id for radio button using same Arraycollection list.my code is
import mx.controls.*;
[Bindable]
private var childName:ArrayCollection;
private var photoFeed:ArrayCollection;
private var arrayOfchild:Array;
[Bindable]
private var childObj:Child;
public var user:SBTSWebService;
public function initApp():void
{
user = new SBTSWebService();
user.addSBTSWebServiceFaultEventListener(handleFaults);
}
public function displayString():void
{
// Instantiate a new Entry object.
var newEntry:GetSBTSMobileAuthentication = new GetSBTSMobileAuthentication();
newEntry.mobile=mobileno.text;
newEntry.password=password.text;
user.addgetSBTSMobileAuthenticationEventListener(authenticationResult);
user.getSBTSMobileAuthentication(newEntry);
}
public function handleFaults(event:FaultEvent):void
{
Alert.show("A fault occured contacting the server. Fault message is: " + event.fault.faultString);
}
public function authenticationResult(event:GetSBTSMobileAuthenticationResultEvent):void
{
if(event.result != null)
{
if(event.result._return > 0)
{
var UserId:int = event.result._return;
getChildList(UserId);
viewstack2.selectedIndex=1;
}
else
{
Alert.show("Authentication fail");
}
}
}
public function getChildList(userId:int):void
{
var childEntry:GetSBTSMobileChildrenInfo = new GetSBTSMobileChildrenInfo();
childEntry.UserId = userId;
user.addgetSBTSMobileChildrenInfoEventListener(sbtsChildrenInfoResult);
user.getSBTSMobileChildrenInfo(childEntry);
}
public function sbtsChildrenInfoResult(event:GetSBTSMobileChildrenInfoResultEvent):void
{
if(event.result != null && event.result._return!=null)
{
arrayOfchild = event.result._return as Array;
photoFeed = new ArrayCollection(arrayOfchild);
childName = new ArrayCollection();
for( var count:int=0;count<photoFeed.length;count++)
{
childObj = photoFeed.getItemAt(count,0) as Child;
childName.addItem(childObj.strName);
}
}
}
]]>
<mx:Panel width="500" height="300"
headerColors="[#000000,#FFFFFF]">
<mx:TabNavigator id="viewstack2" selectedIndex="0" creationPolicy="all"
width="100%" height="100%">
<mx:Form label="Login Form">
<mx:FormItem label="Mobile NO:">
<mx:TextInput id="mobileno" />
</mx:FormItem>
<mx:FormItem label="Password:">
<mx:TextInput displayAsPassword="true" id="password" />
</mx:FormItem>
<mx:FormItem>
<mx:Button label="Login" click="displayString()"/>
</mx:FormItem>
</mx:Form>
<mx:Form label="Child List">
<mx:Label width="100%" color="blue"
text="Select Child."/>
<mx:RadioButtonGroup id="radioGroup" />
<mx:Repeater id="fieldRepeater"
dataProvider="{childName}">
<mx:RadioButton groupName="radioGroup"
label="{fieldRepeater.currentItem}"/>
</mx:Repeater>
</mx:Form>
<mx:Form label="Child Information">
</mx:Form>
<mx:Form label="Trace Path">
</mx:Form>
</mx:TabNavigator>
</mx:Panel>
please tell me the sol.