• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

States & TextInputs

New Here ,
Aug 27, 2011 Aug 27, 2011

Copy link to clipboard

Copied

Got a strange (as I see it) problem. I've got a few different states, with some TextInputs in each.

When I try to call a function to grab the text in each TextInput, I'm only getting the values for one state. When I call the function a second time, I get the values from the 1st & 2nd states, and again if I click the button for the third time, I get all values and the function can complete.

Anybody seen this before or understand why!?

Steve

Views

441

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Aug 27, 2011 Aug 27, 2011

Copy link to clipboard

Copied

Show us some code...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 28, 2011 Aug 28, 2011

Copy link to clipboard

Copied

Good point, sorry!

Here's the MXML:

<?xml version="1.0" encoding="utf-8"?>

<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"

           xmlns:s="library://ns.adobe.com/flex/spark"

           xmlns:mx="library://ns.adobe.com/flex/mx"

           xmlns:coursesservice="services.coursesservice.*"

           xmlns:classesservice="services.classesservice.*"

           xmlns:studentsservice="services.studentsservice.*"

           xmlns:valueObjects="valueObjects.*"

           width="960" height="600" currentState="search"

           height.studentDetails="800">

     

     <fx:Script source="AS/searchName.as"/>

     <s:states>

          <s:State name="search"/>

          <s:State name="studentDetails"/>

          <s:State name="addressDetails"/>

          <s:State name="parentDetails"/>

          <s:State name="emergencyDetails"/>

     </s:states>

     

     <fx:Declarations>

          <s:CallResponder id="searchStudentsResult"/>

          <s:CallResponder id="getStudentsByIDResult"/>

          <s:CallResponder id="getAllCoursesResult"/>

          <s:CallResponder id="getAllClassesResult"/>

          <s:CallResponder id="getCoursesByIDResult"/>

          <s:CallResponder id="getClassesbyCourseResult"/>

          

          <studentsservice:StudentsService id="studentsService"

                                                   fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"

                                                   showBusyCursor="true"/>

          <s:CallResponder id="updateStudentsResult"/>

          <valueObjects:Students id="studentRecord"/>

          

          <classesservice:ClassesService id="classesService" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true" result="classesResult()"/>

          <coursesservice:CoursesService id="coursesService" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true" result="coursesResult()"/>

     </fx:Declarations>

     <s:Label x="10" y="10" fontSize="15" fontWeight="bold" text="Search by name" includeIn="search"/>

     <s:DataGrid id="studentsDataGrid" includeIn="search" x="10" y="86" width="700" height="239"

                    click="itemClickEvent(event)" doubleClickEnabled="true" requestedRowCount="5">

          <s:columns>

               <s:ArrayList>

                    <s:GridColumn dataField="studentref" headerText="studentref"></s:GridColumn>

                    <s:GridColumn dataField="firstname" headerText="firstname"></s:GridColumn>

                    <s:GridColumn dataField="lastname" headerText="lastname"></s:GridColumn>

                    <s:GridColumn dataField="dob" headerText="dob"></s:GridColumn>

                    <s:GridColumn dataField="startdate" headerText="startdate"></s:GridColumn>

               </s:ArrayList>

          </s:columns>

          <s:AsyncListView list="{TypeUtility.convertToCollection(searchStudentsResult.lastResult)}"/>

     </s:DataGrid>

     <s:TextInput id="searchText" includeIn="search" x="10" y="56" width="170"/>

     <s:Button id="btnSearch" includeIn="search" x="184" y="57" label="Search"

                 click="btnSearch_clickHandler(event)"/>

     <s:Label includeIn="search" x="10" y="36" text="Enter at least part of first name or surname:"/>

     <s:Label id="lblStatus" includeIn="search" x="10" y="332" color="#E91010" fontSize="14"/>

     <s:TextInput id="soscontactInput" includeIn="emergencyDetails" x="195" y="48"

                     text="{getStudentsByIDResult.lastResult.soscontact}"/>

     <s:TextInput id="sosrelationInput" includeIn="emergencyDetails" x="195" y="77"

                     text="{getStudentsByIDResult.lastResult.sosrelation}"/>

     <s:TextInput id="sosphoneInput" includeIn="emergencyDetails" x="195" y="107"

                     text="{getStudentsByIDResult.lastResult.sosphone}"/>

     <s:TextInput id="sosmobileInput" includeIn="emergencyDetails" x="195" y="135"

                     text="{getStudentsByIDResult.lastResult.sosmobile}"/>

     <s:TextInput id="medicalnotesInput" includeIn="emergencyDetails" x="195" y="165"

                     text="{getStudentsByIDResult.lastResult.medicalnotes}"/>

     <s:Label includeIn="emergencyDetails" x="10" y="170" text="Medical Notes"/>

     <s:Label includeIn="emergencyDetails" x="10" y="140" text="Emergency Mobile"/>

     <s:Label includeIn="emergencyDetails" x="10" y="112" text="Emergency Phone"/>

     <s:Label includeIn="emergencyDetails" x="10" y="82" text="Emergency Contact Relationship"/>

     <s:Label includeIn="emergencyDetails" x="10" y="53" text="Emergency Contact"/>

     <s:TextInput id="parenthomephoneInput" includeIn="parentDetails" x="195" y="78"

                     text="{getStudentsByIDResult.lastResult.parenthomephone}"/>

     <s:TextInput id="parentnamesInput" includeIn="parentDetails" x="195" y="48"

                     text="{getStudentsByIDResult.lastResult.parentnames}"/>

     <s:Label includeIn="parentDetails" x="10" y="53" text="Parents Names"/>

     <s:TextInput id="parentworkphoneInput" includeIn="parentDetails" x="195" y="109"

                     text="{getStudentsByIDResult.lastResult.parentworkphone}"/>

     <s:TextInput id="fathermobileInput" includeIn="parentDetails" x="195" y="143"

                     text="{getStudentsByIDResult.lastResult.fathermobile}"/>

     <s:TextInput id="mothermobileInput" includeIn="parentDetails" x="195" y="174"

                     text="{getStudentsByIDResult.lastResult.mothermobile}"/>

     <s:TextInput id="fatheremailInput" includeIn="parentDetails" x="195" y="208"

                     text="{getStudentsByIDResult.lastResult.fatheremail}"/>

     <s:TextInput id="motheremailInput" includeIn="parentDetails" x="195" y="243"

                     text="{getStudentsByIDResult.lastResult.motheremail}"/>

     <s:Label includeIn="parentDetails" x="10" y="248" text="Mother Email"/>

     <s:Label includeIn="parentDetails" x="10" y="213" text="Father Email"/>

     <s:Label includeIn="parentDetails" x="10" y="181" text="Mothers Mobile"/>

     <s:Label includeIn="parentDetails" x="10" y="148" text="Fathers Mobile"/>

     <s:Label includeIn="parentDetails" x="10" y="114" text="Parents Work Phone"/>

     <s:Label includeIn="parentDetails" x="10" y="84" text="Parents Home Phone"/>

     <s:TextInput id="termpcodeInput" includeIn="addressDetails" x="195" y="140"

                     text="{getStudentsByIDResult.lastResult.termpcode}"/>

     <s:TextInput id="termaddrInput" includeIn="addressDetails" x="195" y="48"

                     text="{getStudentsByIDResult.lastResult.termaddr}"/>

     <s:TextInput id="termaddr2Input" includeIn="addressDetails" x="195" y="79"

                     text="{getStudentsByIDResult.lastResult.termadd2}"/>

     <s:TextInput id="termcityInput" includeIn="addressDetails" x="195" y="109"

                     text="{getStudentsByIDResult.lastResult.termcity}"/>

     <s:Label includeIn="addressDetails" x="10" y="114" text="Term City"/>

     <s:Label includeIn="addressDetails" x="10" y="84" text="Term Address 2"/>

     <s:Label includeIn="addressDetails" x="10" y="53" text="Term Address"/>

     <s:TextInput id="termphoneInput" includeIn="addressDetails" x="195" y="172"

                     text="{getStudentsByIDResult.lastResult.termphone}"/>

     <s:TextInput id="parentpcodeInput" includeIn="addressDetails" x="585" y="139"

                     text="{getStudentsByIDResult.lastResult.parentpcode}"/>

     <s:TextInput id="parentaddrInput" includeIn="addressDetails" x="585" y="47"

                     text="{getStudentsByIDResult.lastResult.parentaddr}"/>

     <s:TextInput id="parentaddr2Input" includeIn="addressDetails" x="585" y="78"

                     text="{getStudentsByIDResult.lastResult.parentaddr2}"/>

     <s:TextInput id="parentcityInput" includeIn="addressDetails" x="585" y="108"

                     text="{getStudentsByIDResult.lastResult.parentcity}"/>

     <s:Label includeIn="addressDetails" x="400" y="113" text="Parents City"/>

     <s:Label includeIn="addressDetails" x="400" y="83" text="Parents Address 2"/>

     <s:Label includeIn="addressDetails" x="400" y="52" text="Parents Address"/>

     <s:Label includeIn="addressDetails" x="400" y="144" text="Parents Postcode"/>

     <s:Label includeIn="addressDetails" x="10" y="177" text="Term Phone"/>

     <s:Label includeIn="addressDetails" x="10" y="145" text="Term Postcode"/>

     <s:TextInput id="firstnameInput" includeIn="studentDetails" x="195" y="140"

                     text="{getStudentsByIDResult.lastResult.firstname}"/>

     <s:TextInput id="studentrefInput" includeIn="studentDetails" x="195" y="48"

                     text="{getStudentsByIDResult.lastResult.studentref}"/>

     <s:Label includeIn="studentDetails" x="10" y="114" text="Class Code"/>

     <s:Label includeIn="studentDetails" x="10" y="84" text="Course Code"/>

     <s:Label includeIn="studentDetails" x="10" y="53" text="Student Ref"/>

     <s:TextInput id="lastnameInput" includeIn="studentDetails" x="195" y="172"

                     text="{getStudentsByIDResult.lastResult.lastname}"/>

     <s:TextInput id="dobInput" includeIn="studentDetails" x="195" y="199"

                     text="{getStudentsByIDResult.lastResult.dob}"/>

     <s:TextInput id="startdateInput" includeIn="studentDetails" x="195" y="228"

                     text="{getStudentsByIDResult.lastResult.startdate}"/>

     <s:TextInput id="studentemailInput" includeIn="studentDetails" x="195" y="257"

                     text="{getStudentsByIDResult.lastResult.studentemail}"/>

     <s:TextInput id="sqanumInput" includeIn="studentDetails" x="195" y="319"

                     text="{getStudentsByIDResult.lastResult.sqanum}"/>

     <s:TextInput id="callhistoryInput" includeIn="studentDetails" x="195" y="348"

                     text="{getStudentsByIDResult.lastResult.callhistory}"/>

     <s:TextInput id="councilInput" includeIn="studentDetails" x="195" y="377"

                     text="{getStudentsByIDResult.lastResult.council}"/>

     <s:TextInput id="ageInput" includeIn="studentDetails" x="195" y="408"

                     text="{getStudentsByIDResult.lastResult.age}"/>

     <s:Label includeIn="studentDetails" x="10" y="413" text="Age"/>

     <s:Label includeIn="studentDetails" x="10" y="382" text="Local Council"/>

     <s:Label includeIn="studentDetails" x="10" y="353" text="Call History"/>

     <s:Label includeIn="studentDetails" x="10" y="324" text="SQA Number"/>

     <s:TextInput id="studentmobileInput" includeIn="studentDetails" x="195" y="288"

                     text="{getStudentsByIDResult.lastResult.studentmobile}"/>

     <s:Label includeIn="studentDetails" x="10" y="293" text="Student Mobile"/>

     <s:Label includeIn="studentDetails" x="10" y="262" text="Student Email"/>

     <s:Label includeIn="studentDetails" x="10" y="233" text="Start Date"/>

     <s:Label includeIn="studentDetails" x="10" y="204" text="D.O.B"/>

     <s:Label includeIn="studentDetails" x="10" y="177" text="Last Name"/>

     <s:Label includeIn="studentDetails" x="10" y="145" text="First Name"/>

     <s:Button includeIn="addressDetails,emergencyDetails,parentDetails,studentDetails" x="10" y="9"

                 label="Student Details" click="this.currentState='studentDetails'"

                 label.studentDetails="Student Details" emphasized.studentDetails="true"/>

     <s:Button includeIn="addressDetails,emergencyDetails,parentDetails,studentDetails" x="129" y="9"

                 label="Address Details" click="this.currentState='addressDetails'"

                 emphasized.addressDetails="true"

                 x.parentDetails="129" y.parentDetails="9"/>

     <s:Button includeIn="addressDetails,emergencyDetails,parentDetails,studentDetails" x="361" y="9"

                 label="Emergency Details" click="this.currentState='emergencyDetails'"

                 emphasized.emergencyDetails="true"

                 x.parentDetails="361" y.parentDetails="9"/>

     <s:Button includeIn="addressDetails,emergencyDetails,parentDetails,studentDetails" x="250" y="9"

                 label="Parent Details" click="this.currentState='parentDetails'"

                 x.parentDetails="250" y.parentDetails="9" emphasized.parentDetails="true"/>

     <s:Button id="button0" includeIn="addressDetails,emergencyDetails,parentDetails,studentDetails"

                 x="10" y="463" width="125" label="Update" click="button_clickHandler(event)"/>

     <mx:HRule includeIn="addressDetails,emergencyDetails,parentDetails,studentDetails" x="0" y="450" width="1200"/>

     <mx:HRule includeIn="addressDetails,emergencyDetails,parentDetails,studentDetails" x="0" y="35"

                 width="495"/>

     <s:DropDownList id="coursecodeInput" includeIn="studentDetails" x="195" y="77" width="128"

                         dataProvider="{getAllCoursesResult.lastResult}" labelField="name"></s:DropDownList>

     <s:DropDownList id="classcodeInput" includeIn="studentDetails" x="195" y="109" width="128" labelField="name" dataProvider="{getAllClassesResult.lastResult}"></s:DropDownList>

     <s:TextArea id="lblError" includeIn="studentDetails" x="623" y="10" width="327" height="780"

                    borderVisible="false"/>

</s:Group>

And the bit of AS:

protected function button_clickHandler(event:MouseEvent):void

{

     studentRecord = null;

     var studentRecord:Students = new Students;

     

     studentRecord.id                    = studentsDataGrid.selectedItem.id;

     studentRecord.studentref            = studentrefInput.text;

     studentRecord.courseid              = coursecodeInput.selectedIndex+1;

     studentRecord.classid               = classcodeInput.selectedIndex+1;

     studentRecord.firstname             = firstnameInput.text || "";

     studentRecord.lastname              = lastnameInput.text || "";

     studentRecord.dob                   = dobInput.text || "";

     studentRecord.startdate             = startdateInput.text || "";

     studentRecord.studentemail          = studentemailInput.text || "";

     studentRecord.studentmobile         = studentmobileInput.text || "";

     studentRecord.sqanum                = sqanumInput.text || "";

     studentRecord.callhistory           = callhistoryInput.text || "";

     studentRecord.council               = councilInput.text || "";

     studentRecord.age                   = parseInt(ageInput.text) || 0;

     

     studentRecord.termaddr              = termaddrInput.text || "";

     studentRecord.termadd2              = termaddr2Input.text || "";

     studentRecord.termcity              = termcityInput.text || "";

     studentRecord.termpcode             = termpcodeInput.text || "";

     studentRecord.termphone             = termphoneInput.text || "";

     

     studentRecord.parentaddr            = parentaddrInput.text || "";

     studentRecord.parentaddr2           = parentaddr2Input.text || "";

     studentRecord.parentcity            = parentcityInput.text || "";

     studentRecord.parentpcode           = parentpcodeInput.text || "";

     

     

     studentRecord.parentnames           = parentnamesInput.text || "";

     studentRecord.parenthomephone       = parenthomephoneInput.text || "";

     studentRecord.parentworkphone       = parentworkphoneInput.text || "";

     studentRecord.fathermobile          = fathermobileInput.text || "";

     studentRecord.mothermobile          = mothermobileInput.text || "";

     studentRecord.fatheremail           = fatheremailInput.text || "";

     studentRecord.motheremail           = motheremailInput.text || "";

     

     studentRecord.soscontact            = soscontactInput.text || "";

     studentRecord.sosrelation           = sosrelationInput.text || "";

     studentRecord.sosphone              = sosphoneInput.text || "";

     studentRecord.sosmobile             = sosmobileInput.text || "";

     studentRecord.medicalnotes          = medicalnotesInput.text || "";

     

     updateStudentsResult.token = studentsService.updateStudents(studentRecord);

     studentsService.commit();

     lblStatus.text = firstnameInput.text + " " + lastnameInput.text + " successfully updated";

     studentRecord = null;

     

     this.currentState = "search";

}

Sorry it's rather long! Let me know if you'd like a trimmed down version.

Cheers

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Aug 28, 2011 Aug 28, 2011

Copy link to clipboard

Copied

I don't know about this specific very strange behavior, but I've had issues with states and accessing form fields.  In some cases I ended up just adding itemCreationPolicy='immediate' next to my includeIns.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 28, 2011 Aug 28, 2011

Copy link to clipboard

Copied

LATEST

Excellent! itemCreationPolicy='immediate' worked perfectly.

Thanks!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines