Flex Repeater

Hello every one,
please use cairngorm.swc file

my question is.
select the number of passengers and when you click on submit button i am going to show the data like passenger DateofBirth field and age feild in the second page.

when i change the date feild to the passenger date of birth i need to populate the age feild with the age of passenger (this should be calculated according to the date selected in date feild) and that should show in years(like if age is one year and two months it should show as 1.2)

and when i click the submit button in second page i need to check whether all the feilds are entered in the repeater.

can anybody help me in this.

Thanks in advance

Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

zzynxConnect With a Mentor Software engineerCommented:
This is my second.mxml
(I hope that is the only thing I changed - it's a while ago I did the changes)
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"  width="100%" height="100%">
			import mx.events.CalendarLayoutChangeEvent;
			import mx.collections.ArrayCollection;
			import mx.controls.DateField;
			public var modellocator:AppModelLocator = AppModelLocator.getinstance();
			public function updateRepeater():void
				var passArr:Array = new Array();
				for(var i:int=0;i<modellocator.numberofPassengers;i++){
					var o:Object = new Object();
					o.age = new Number(0);
					o.birthday = new Date();
				passInformation.dataProvider = passArr; 
			private function proceedHandler(event:MouseEvent):void{
				modellocator.passinfArrayColl = new ArrayCollection();
				for(var j:int=0 ; j<modellocator.numberofPassengers; j++ ){
					var item:Object = new Object;
					item.age = AGE[j].text;
					item.dob = DOB[j].text;
				modellocator.workflowState = AppModelLocator.LAST;
			private function onDateChange(event:CalendarLayoutChangeEvent):void {
			    var df:DateField = event.currentTarget as DateField;

				var date:Date = df.selectedDate;
				var now:Date = new Date();
				var day:Number = date.date;
				var month:Number = date.month;
				var year:Number = date.fullYear; 
				var ageInMonths:Number = -1;
				while (date.getTime() < now.getTime()) {
					if (month==11) {
						year = year+1;
						month = 0;
					} else {
					date = new Date(year, month, day);
				trace("Age in months = ", ageInMonths);
				df.getRepeaterItem().age = ageInMonths;
				df.getRepeaterItem().birthday = df.selectedDate;
	<mx:VBox width="100%" top="10">
	<mx:VBox width="100%" verticalGap="2" horizontalGap="2">
		<mx:Canvas width="100%">
			<mx:Label text="AGE" fontWeight="bold" x="135"/>
			<mx:Label text="DOB" fontWeight="bold" x="206"/>
	<mx:VBox id="passInf" width="100%" verticalGap="2" horizontalGap="2">
		<mx:Repeater id="passInformation"   >
			<mx:Form >
				<mx:FormItem label="Passenger Details:" required="true" direction="horizontal">
					<mx:TextInput id="AGE" editable="false" text="{passInformation.currentItem.age}" width="39"/>
					<mx:DateField id="DOB" yearNavigationEnabled="true" selectedDate="{passInformation.currentItem.birthday}" change="onDateChange(event)"/>					
	<mx:Button label="Proceed" click="proceedHandler(event)" x="163.5" y="243"/>

Open in new window

zzynxSoftware engineerCommented:
>> if age is one year and two months it should show as 1.2
one year and 1 month = 1.1
one year and 10 months = 1.10 also?

Since 2 months = 2/12 or 1/6 or 0.16666 year shouldn't that be 1.1666666?
srujanmiryalaAuthor Commented:
Hello ZZynx,
Sorry for the late reply.i was waiting for the confirmation how the age should be displayed.
it should be disaplayed in months(i.e one year and 1 month = 13).
Live webcast with Pinal Dave

Pinal Dave will teach you tricks to help identify the real root cause of database problems rather than red herrings. Attendees will learn scripts that they can use in their environment to immediately figure out their performance Blame Shifters and fix them quickly.

zzynxSoftware engineerCommented:
In second.mxml there's

    for(var i:int=0;i<modellocator.numberofPassengers;i++) {

while numberofPassengers is undefined in AppModelLocator.
Same for



srujanmiryalaAuthor Commented:
      import com.adobe.cairngorm.model.IModelLocator;
      import mx.collections.ArrayCollection;
      public class AppModelLocator implements IModelLocator
            public static var instance:AppModelLocator;
            public function AppModelLocator(enforcer:SingletonEnforcer)
                  if (enforcer == null)
                        throw new Error("You can only have one modal locator");
            public static function getinstance():AppModelLocator
                  if (instance == null)
                        instance = new AppModelLocator(new SingletonEnforcer);
                  return instance;
            // Define Variablea
            public var workflowState:uint = 0;
            // Number of passengers
                                          public var numberofPassengers:int;
            public var passinfArrayColl:ArrayCollection;
            // Define Constants
            public static const FIRST:uint = 0;
            public static const SECOND:uint = 1;
            public static const LAST:uint = 2;

class SingletonEnforcer{}
srujanmiryalaAuthor Commented:
hey zzynx:

Did you find any solution for this i have kept the model locator code in previous comment
srujanmiryalaAuthor Commented:
Hey You are Excellent
Thank you very much.
Onemore Question after clicking the proceed button and before navigating to last page i need to check whether all the feild in the repeater are entered or not. how to do this.
zzynxSoftware engineerCommented:
thanx 4 axxepting

>> Onemore Question after clicking the proceed button and before navigating to last page i need to check whether all the feild in the repeater are entered or not. how to do this.
All Courses

From novice to tech pro — start learning today.