1

在我的 flex 移动项目中,我有 2 个视图

  1. 是调查列表
  2. 是调查问题列表

每个调查对对象都有不同的问题,从视图 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>
4

2 回答 2

0

好的,感谢您澄清那部分,所以我的理解是 MXML 中的绑定工作正常,您根本不知道如何检索您传递给服务第二次调用的参数?如果是这样,您应该能够在 PHP 中使用 $_REQUEST 或 $_POST 或 $_GET ,具体取决于您在服务上设置的 HTTP 方法(或者默认情况下使用的任何方法,我相信 AS3 服务类默认情况下通常是 GET )。

相反,如果您的问题只是您想知道数据何时进入并在那时进行调用,那么您只需要覆盖设置数据,例如

override public function set data(value:Object):void
{
    super.data = value;
    if(!data || data == value)
         return;
    getSurveyQuestionsResult.token = surveyquestionsService.getSurveyQuestions(data);
}
于 2012-09-26T00:27:54.853 回答
0

我在搜索一种方法以将多个参数传递给 pushView 方法调用的另一个视图时偶然发现了这里。我通过这个问题发现的是,我可以传递一个 Object 类型的参数,并为这个参数创建我需要的任意数量的自定义属性。

例如,我需要传递一个字符串和一个数组,我这样做了:

在调用者视图中:

var viewParameters:Object = new Object();
viewParameters.stringParam = myString;
viewParameters.listParam = myList;
navigator.pushView(CalledView, viewParameters);

在被调用的视图中:

var myString:String = data.stringParam;
var myList:Array = data.listParam as Array;

此处不需要覆盖集数据功能,因为我正在调用已填充数据的 pushView。

于 2014-02-11T11:26:49.340 回答