在我的Flex移動項目,我有2次FLEX通行證視圖之間的多個數據 - 利用接收到的數據來查詢數據庫
- 是調查的名單
- 是調查問題清單
每個調查對象都有不同的問題,從視圖1的列表中選擇一個調查,並將記錄ID傳遞到視圖2上,以根據該ID查詢數據。
我在掙扎的地方是取得調查ID,並將它傳遞給第2頁的動作,從那裏我將檢索參數化數據。
所有提示讚賞。
我的第1碼
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:surveynameservice="services.surveynameservice.*"
title="surveyMaster">
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
import spark.events.IndexChangeEvent;
protected function list_creationCompleteHandler(event:FlexEvent):void
{
getAllSurveynameResult.token = surveynameService.getAllSurveyname();
}
protected function surveySelected(event:IndexChangeEvent):void
{
// TODO Auto-generated method stub
var tmpObj:Object = new Object();
tmpObj.sID = list.selectedItem.surveyID;
tmpObj.sName = list.selectedItem.surveyName;
(this.parentDocument as cp_dbHomeView).rightNav.activeView.data=tmpObj;
}
]]>
</fx:Script>
<fx:Declarations>
<s:CallResponder id="getAllSurveynameResult"/>
<surveynameservice:SurveynameService id="surveynameService"/>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:List id="list" x="-1" y="0" width="171" height="100%" change="surveySelected(event)"
creationComplete="list_creationCompleteHandler(event)" labelField="surveyName">
<s:AsyncListView list="{getAllSurveynameResult.lastResult}"/>
</s:List>
</s:View>
我的第2碼
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:surveyquestionsservice="services.surveyquestionsservice.*"
creationComplete="init()" title="{data.sID}">
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
import spark.components.DataRenderer;
public function init():void{
}
protected function list_creationCompleteHandler(event:FlexEvent):void
{
getSurveyQuestionsResult.token = surveyquestionsService.getSurveyQuestions(data);
}
]]>
</fx:Script>
<s:layout>
<s:VerticalLayout paddingTop="15" paddingBottom="15" paddingLeft="15" paddingRight="15" gap="5"
horizontalAlign="center" verticalAlign="top"/>
</s:layout>
<fx:Declarations>
<s:CallResponder id="getSurveyQuestionsResult"/>
<surveyquestionsservice:SurveyquestionsService id="surveyquestionsService"/>
</fx:Declarations>
<s:Label text="Click on a location on the left to explore!" visible="{data==null?true:false}"/>
<s:Label text="Information about {this.data.surveyID}" visible="{data!=null?true:false}"/>
<s:TextArea text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur accumsan felis ac tortor aliquam iaculis. Phasellus hendrerit viverra enim, sit amet scelerisque lectus dictum at. Aenean sodales nisi sed leo congue et porttitor ligula vehicula.
Pellentesque turpis massa, suscipit vel fermentum quis, dignissim sed ipsum. Nulla aliquet libero adipiscing risus lobortis eleifend quis at velit. Duis at leo urna.
Praesent facilisis faucibus neque, ut ullamcorper lacus gravida a. Donec vel iaculis sapien." width="90%" editable="false" visible="{data!=null?true:false}"/>
<s:List id="list" width="659" creationComplete="list_creationCompleteHandler(event)" click="init()"
labelField="questionDesc">
<s:AsyncListView list="{getSurveyQuestionsResult.lastResult}"/>
</s:List>
</s:View>
頁面1和頁面2之間的關係是什麼,如果給出的名字在描述它時可能有點幫助。基本上,如果這些東西有父母/孩子的關係,你可以使用事件或直接在兩者之間傳遞對象,如果他們是兄弟姐妹,則需要有兩個處理器的類來做一些工作來偵聽來自一個事件的事件並將這些數據傳遞給另一個。所以請描述使用page1和page2的文件,顯示從一個移動到另一個的代碼會有所幫助。 – shaunhusain
關係是第一頁是調查列表,第二頁是關於調查的問題。我創建並傳遞視圖1中的對象,將它傳遞給頁面2,然後在頁面2中可用數據,在這裏我很難將該數據檢索到動作腳本中,然後將該參數傳遞給我的PHP頁面。 –