Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 532
  • Last Modified:

Loaded Data from MYSQL is not showed correctly in ViewStack

Hello!

I´m loading some data from a MYSQL database into a DataGrid. This DataGrid is in ViewStack 1. When i click an item in the DataGrid, ViewStack 2 is opening and show´s the whole user data.

Now i have this problem that i get an error at clicking an item:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
      at test_kunden/eventListener()[/Users/marioboro/Documents/Flex Builder 3/Kundenverwaltung/src/test_kunden.mxml:14]
      at test_kunden/__dgUserRequest_change()[/Users/marioboro/Documents/Flex Builder 3/Kundenverwaltung/src/test_kunden.mxml:51]
      at flash.events::EventDispatcher/dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at mx.core::UIComponent/dispatchEvent()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:9298]
      at mx.controls.listClasses::ListBase/mouseUpHandler()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\controls\listClasses\ListBase.as:8989]
      at mx.controls::DataGrid/mouseUpHandler()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\controls\DataGrid.as:4337]

When i close ViewStack 2 and go back to ViewStack 1 and click another item (row), then ViewStack 2 is open with the correctly loaded user data.

Please can somebody help me what´s wrong?

Thank´s!
Mario
<?xml version="1.0" encoding="utf-8"?>
<mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="960" height="650" xmlns="*" creationComplete="send_data()">
 
<mx:Script> 
 
	private function send_data():void {
  	userRequest.send();
  	}
 
  	public function eventListener(event:Event):void
	{
	anrede.text = dgUserRequest.selectedItem.anrede;
	usernachname.text = dgUserRequest.selectedItem.usernachname;
	username.text = dgUserRequest.selectedItem.username;
	plz.text = dgUserRequest.selectedItem.plz;
	ort.text = dgUserRequest.selectedItem.ort;
	strasse.text = dgUserRequest.selectedItem.strasse;
	tel_privat.text = dgUserRequest.selectedItem.tel_privat;
	emailaddress.text = dgUserRequest.selectedItem.emailaddress;
	userid.text = dgUserRequest.selectedItem.userid;
	gebdatum.text = dgUserRequest.selectedItem.gebdatum;
	beruf.text = dgUserRequest.selectedItem.beruf;
	sonstiges.text = dgUserRequest.selectedItem.sonstiges;
	dw_datum.selectedDate = dgUserRequest.selectedItem.dw_datum;
	dw_bedienung.text = dgUserRequest.selectedItem.dw_bedienung;
	dw_wickler.text = dgUserRequest.selectedItem.dw_wickler;
	dw_anordnung.text = dgUserRequest.selectedItem.dw_anordnung;
	dw_einwirkzeit.text = dgUserRequest.selectedItem.dw_einwirkzeit;
	dw_nachbehandlung.text = dgUserRequest.selectedItem.dw_nachbehandlung;
	dw_preis.text = dgUserRequest.selectedItem.dw_preis;
	dw_anmerkungen.text = dgUserRequest.selectedItem.dw_anmerkungen;
	image_url.source= dgUserRequest.selectedItem.image_url;
	fa_datum.text = dgUserRequest.selectedItem.fa_datum;
	fa_bedienung.text = dgUserRequest.selectedItem.fa_bedienung;
	fa_rezeptur.text = dgUserRequest.selectedItem.fa_rezeptur;
	fa_einwirkzeit.text = dgUserRequest.selectedItem.fa_einwirkzeit;
	fa_preis.text = dgUserRequest.selectedItem.fa_preis;
	fa_anmerkungen.text = dgUserRequest.selectedItem.fa_anmerkungen;  
	userRequest.send();
	}
 
</mx:Script>
 
<mx:VBox>
 
	<mx:ViewStack id="kunden_mutter" width="960">
	<mx:Canvas id="kunden_1" label="Kunden">
	
		<mx:DataGrid change="eventListener(event)" id="dgUserRequest" x="0" y="0" dataProvider="{userRequest.lastResult.users.user}" width="940" height="593" click="kunden_mutter.selectedChild=kunden_detail;" fontSize="11">
  		<mx:columns>
    		<mx:DataGridColumn headerText="Nr." dataField="userid" width="35" itemRenderer="CustomRenderer" sortable="false"/>
    		<mx:DataGridColumn headerText="Anrede" dataField="anrede" width="65" itemRenderer="CustomRenderer"/>
    		<mx:DataGridColumn headerText="Nachname" dataField="usernachname" width="200" itemRenderer="CustomRenderer"/>
    		<mx:DataGridColumn headerText="Vorname" dataField="username" width="110" itemRenderer="CustomRenderer" sortable="false"/>
    		<mx:DataGridColumn headerText="Plz" dataField="plz" width="50" itemRenderer="CustomRenderer"/>
    		<mx:DataGridColumn headerText="Ort" dataField="ort" width="190" itemRenderer="CustomRenderer"/>
    		<mx:DataGridColumn headerText="Straße" dataField="strasse" width="200" itemRenderer="CustomRenderer" sortable="false"/>
    		<mx:DataGridColumn headerText="Telefon Nr." dataField="tel_privat" width="110" itemRenderer="CustomRenderer" sortable="false"/>
  		</mx:columns>
		</mx:DataGrid>
    </mx:Canvas>
 
	<mx:Canvas id="kunden_detail" label="Details">
    	<mx:Form x="0" y="0" width="100%" >
 
  		<mx:Canvas id="personenDaten" width="100%">
  
    	<mx:constraintColumns>
      	<mx:ConstraintColumn id="col1" width="0" />
      	<mx:ConstraintColumn id="col2" width="50%" />
      	<mx:ConstraintColumn id="col3" width="50%" />
    	</mx:constraintColumns>
    
    	<mx:Panel dropShadowEnabled="false" title="Angaben zur Person" width="400" height="100%" left="col2:0" paddingLeft="10" paddingBottom="10" paddingRight="10" paddingTop="10">
      
      	<mx:HBox>
        <mx:Label text="Kunden Nr." textAlign="left" fontWeight="bold" width="100"/>
        <mx:TextInput id="userid" text="id" editable="false" width="60"/>
      	</mx:HBox>
      
      	<mx:HRule width="358" strokeWidth="2" strokeColor="#0B333C"/>
      
      	<mx:HBox left="50" top="50">
        <mx:Label text="Anrede" fontWeight="bold" width="100"/>
        <mx:TextInput id="anrede"  width="60"/>
      	</mx:HBox>
      
      	<mx:HBox>
        <mx:Label text="Nachname" fontWeight="bold" width="100"/>
        <mx:TextInput id="usernachname"  width="250"/>
      	</mx:HBox>
     
      	<mx:HBox>
        <mx:Label text="Vorname" fontWeight="bold" width="100"/>
        <mx:TextInput id="username"  width="250"/>
      	</mx:HBox>
      
      	<mx:HBox>
        <mx:Label text="Plz/Ort" fontWeight="bold" width="100"/>
        <mx:TextInput id="plz"  width="60"/>
        <mx:TextInput id="ort"  width="182"/>
      	</mx:HBox>
      
      	<mx:HBox>
        <mx:Label text="Straße" fontWeight="bold" width="100"/>
        <mx:TextInput id="strasse"  width="250"/>
      
      	</mx:HBox>
      	<mx:HRule width="358" strokeWidth="2" strokeColor="#0B333C"/>
      
      	<mx:HBox>
        <mx:Label text="Tel. Privat" fontWeight="bold" width="100"/>
        <mx:TextInput id="tel_privat"  width="250"/>
      	</mx:HBox>
      
      	<mx:HBox>
        <mx:Label text="E-Mail" fontWeight="bold" width="100"/>
        <mx:TextInput id="emailaddress"  width="250"/>
      	</mx:HBox>
      
      	<mx:HRule width="358" strokeWidth="2" strokeColor="#0B333C"/>
 
      	<mx:HBox>
        <mx:Label text="Geb. Datum" fontWeight="bold" width="100"/>
        <mx:TextInput id="gebdatum" />
        <!--<mx:DateField id="gebdatum" formatString="DD.MM.YYYY" yearNavigationEnabled="true" />-->
      
      	</mx:HBox>
      	<mx:HBox>
        <mx:Label text="Beruf" fontWeight="bold" width="100"/>
        <mx:TextInput id="beruf"  width="250"/>
      	</mx:HBox>
      
      	<mx:HRule width="358" strokeWidth="2" strokeColor="#0B333C"/>
      
      	<mx:Text text="Sonstiges" fontWeight="bold" fontSize="11"/>
      	<mx:TextArea id="sonstiges" width="358" height="200"/>
      
      	<mx:HBox width="100%" horizontalAlign="center">
      	<mx:Button label="Speichern" id="submit" click="send_data()"/><mx:Button label="Schliessen" id="close" click="kunden_mutter.selectedChild=kunden_1;"/>
 
      	</mx:HBox>
    
    	</mx:Panel>
    
    	<mx:Panel dropShadowEnabled="false" title="Weitere Infos" height="100%" paddingLeft="10" paddingBottom="10" paddingRight="10" paddingTop="10" left="422" width="540">
      
      	<mx:HBox width="100%" horizontalAlign="left">
        <mx:Image id="image_url" width="237" height="178"/>
      	</mx:HBox>
      
      	<mx:HRule width="100%" strokeWidth="2" strokeColor="#0B333C"/>
 
        <mx:Accordion id="accordion" width="100%" height="100%" creationPolicy="all">
        <mx:VBox label="Dauerwelle" fontSize="11" fontWeight="normal" paddingLeft="10" paddingBottom="10" paddingRight="10" paddingTop="10">
                
        <mx:HBox>
        <mx:Label text="Datum" fontWeight="bold" width="100"/>
        <!--<mx:TextInput id="dw_datum"  width="100"/>-->
        <mx:DateField id="dw_datum" formatString="YYYY-MM-DD"/>
        <mx:Label text="Bedient von" fontWeight="bold" width="85"/>
        <mx:TextInput id="dw_bedienung"  width="157"/>
      	</mx:HBox>
      			
      	<mx:HBox>
        <mx:Label text="Wicklerstärke" fontWeight="bold" width="100"/>
        <mx:TextInput id="dw_wickler"  width="358"/>
      	</mx:HBox>
      	
      	<mx:HBox>
        <mx:Label text="Anordnung" fontWeight="bold" width="100"/>
        <mx:TextInput id="dw_anordnung"  width="358"/>
      	</mx:HBox>
      		
      	<mx:HBox>
        <mx:Label text="Einwirkzeit" fontWeight="bold" width="100"/>
        <mx:TextInput id="dw_einwirkzeit"  width="100"/>
        <mx:Label text="Nachbehandlung" fontWeight="bold" width="122"/>
        <mx:TextInput id="dw_nachbehandlung"  width="120"/>
      	</mx:HBox>
      		
      	<mx:HBox>
        <mx:Label text="Preis" fontWeight="bold" width="100"/>
        <mx:TextInput id="dw_preis"  width="358"/>
      	</mx:HBox>
      		
      	<mx:HBox>
        <mx:Label text="Anmerkungen" fontWeight="bold" width="100"/>
        <mx:TextArea id="dw_anmerkungen" width="358" height="100"/>
      	</mx:HBox>
   
        </mx:VBox>
 
        <mx:VBox label="Farbe" fontSize="11" fontWeight="normal" paddingLeft="10" paddingBottom="10" paddingRight="10" paddingTop="10">
            
        <mx:HBox>
        <mx:Label text="Datum" fontWeight="bold" width="100"/>
        <mx:TextInput id="fa_datum"  width="358"/>
      	</mx:HBox>
      			
      	<mx:HBox>
        <mx:Label text="Bedient von" fontWeight="bold" width="100"/>
        <mx:TextInput id="fa_bedienung"  width="358"/>
      	</mx:HBox>
      			
      	<mx:HBox>
        <mx:Label text="Rezeptur" fontWeight="bold" width="100"/>
        <mx:TextInput id="fa_rezeptur"  width="358"/>
      	</mx:HBox>
      		
      	<mx:HBox>
        <mx:Label text="Einwirkzeit" fontWeight="bold" width="100"/>
        <mx:TextInput id="fa_einwirkzeit"  width="358"/>
      	</mx:HBox>
      			
      	<mx:HBox>
        <mx:Label text="Preis" fontWeight="bold" width="100"/>
        <mx:TextInput id="fa_preis"  width="358"/>
      	</mx:HBox>
      			
      	<mx:HBox>
        <mx:Label text="Anmerkungen" fontWeight="bold" width="100"/>
        <mx:TextArea id="fa_anmerkungen" width="358" height="100"/>
      	</mx:HBox>
      			
        </mx:VBox>
        </mx:Accordion>
      
    </mx:Panel>
    
  </mx:Canvas>
  
</mx:Form>
</mx:Canvas>
 
</mx:ViewStack>
</mx:VBox>
 
<mx:HTTPService id="userRequest" url="http://localhost/kunden.php" useProxy="false" method="POST">
  <mx:request xmlns="">
    <userid>{userid.text}</userid>
    <anrede>{anrede.text}</anrede>
    <username>{username.text}</username>
    <usernachname>{usernachname.text}</usernachname>
    <plz>{plz.text}</plz>
    <ort>{ort.text}</ort>
    <strasse>{strasse.text}</strasse>
    <tel_privat>{tel_privat.text}</tel_privat>
    <emailaddress>{emailaddress.text}</emailaddress>
    <gebdatum>{gebdatum.text}</gebdatum>
    <beruf>{beruf.text}</beruf>
    <sonstiges>{sonstiges.text}</sonstiges>
    <dw_datum>{dw_datum.selectedDate}</dw_datum>
    <dw_bedienung>{dw_bedienung.text}</dw_bedienung>
    <dw_wickler>{dw_wickler.text}</dw_wickler>
    <dw_anordnung>{dw_anordnung.text}</dw_anordnung>
    <dw_einwirkzeit>{dw_einwirkzeit.text}</dw_einwirkzeit>
    <dw_nachbehandlung>{dw_nachbehandlung.text}</dw_nachbehandlung>
    <dw_preis>{dw_preis.text}</dw_preis>
    <dw_anmerkungen>{dw_anmerkungen.text}</dw_anmerkungen>
    <fa_datum>{fa_datum.text}</fa_datum>
    <fa_bedienung>{fa_bedienung.text}</fa_bedienung>
    <fa_rezeptur>{fa_rezeptur.text}</fa_rezeptur>
    <fa_einwirkzeit>{fa_einwirkzeit.text}</fa_einwirkzeit>
    <fa_preis>{fa_preis.text}</fa_preis>
    <fa_anmerkungen>{fa_anmerkungen.text}</fa_anmerkungen>
  </mx:request>
</mx:HTTPService>
 
</mx:Module>

Open in new window

0
20one
Asked:
20one
  • 2
1 Solution
 
20oneAuthor Commented:
Solution:
The data is loaded but the items from ViewStack 2 are not loaded when i chnage from 1 to 2. Now i have wrote (creationPolicy="all") in the ViewStack and it works fine.
0
 
Jones911Commented:
Glad its working.  I know that yuo have to watch out with the tabset aswell.  Subtabs arnt created untill you click it.
0
 
20oneAuthor Commented:
Thank´s Jones911!
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now