Flex:如何访问 Flex 表单中的数据并将其提交到 ColdFusion cfc?

发布于 2024-07-09 21:15:55 字数 1258 浏览 9 评论 0原文

我想将 Flex 表单的值提交到 ColdFusion cfc。

如果我有一个弹性表单(见下文),表单中的数据是一个对象吗? 或者我是否必须根据表单中的 id 创建一个对象,然后将该新对象传递给 Coldfusion 组件?

<mx:Form x="10" y="10" width="790" id="myFrom" defaultButton="{createReport}">
    <mx:FormItem label="Resume Report Type:">
    <mx:RadioButtonGroup id="showtype"/>
    <mx:HBox>
        <mx:RadioButton groupName="showtype" id="NotUpdated" value="notupdated" label="Not Updated" width="100"  />
        <mx:RadioButton groupName="showtype" id="Updated" value="updated" label="Updated" width="75"  />
        <mx:RadioButton groupName="showtype" id="All" value="all" label="All" width="75"  />
    </mx:HBox>
    </mx:FormItem>
    <mx:FormItem label="User Organzation:">
        <mx:ComboBox dataProvider="{qOrganization}" labelField="UserOrganization" />    </mx:FormItem>

    <mx:FormItem label="Between the following dates:">
        <mx:HBox>
            <mx:DateField/>
            <mx:DateField left="10"/>
        </mx:HBox>
    </mx:FormItem>
    <mx:FormItem>

        <mx:Button label="Create Report" id="createReport"/>
    </mx:FormItem>  
    </mx:Form>

I want to submit the values of a flex form to a ColdFusion cfc.

If I have a flex form (see below) is the data in the form an object? Or do I have to create an object based on the id's in the form and then pass that new object to the coldfusion component?

<mx:Form x="10" y="10" width="790" id="myFrom" defaultButton="{createReport}">
    <mx:FormItem label="Resume Report Type:">
    <mx:RadioButtonGroup id="showtype"/>
    <mx:HBox>
        <mx:RadioButton groupName="showtype" id="NotUpdated" value="notupdated" label="Not Updated" width="100"  />
        <mx:RadioButton groupName="showtype" id="Updated" value="updated" label="Updated" width="75"  />
        <mx:RadioButton groupName="showtype" id="All" value="all" label="All" width="75"  />
    </mx:HBox>
    </mx:FormItem>
    <mx:FormItem label="User Organzation:">
        <mx:ComboBox dataProvider="{qOrganization}" labelField="UserOrganization" />    </mx:FormItem>

    <mx:FormItem label="Between the following dates:">
        <mx:HBox>
            <mx:DateField/>
            <mx:DateField left="10"/>
        </mx:HBox>
    </mx:FormItem>
    <mx:FormItem>

        <mx:Button label="Create Report" id="createReport"/>
    </mx:FormItem>  
    </mx:Form>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

或十年 2024-07-16 21:15:55

没有数据绑定到表单中的任何控件(ComboBox 的 dataProvider 除外)。 如果您想通过最少的修改从表单中提取数据,请为每个控件分配一个“id”属性,并从 ActionScript 以编程方式访问它们:

var obj : MyObject = new MyObject();
obj.beginDate = beginDate.selectedDate;
obj.endDate = endDate.selectedDate;
obj.organization = Organization(comboOrg.selectedItem);
// etc

There is no data bound to any of the controls in the form (except for the dataProvider for the ComboBox). If you want to extract the data from the form with minimal modifications, assign an "id" property to each control and the access them programmatically from ActionScript:

var obj : MyObject = new MyObject();
obj.beginDate = beginDate.selectedDate;
obj.endDate = endDate.selectedDate;
obj.organization = Organization(comboOrg.selectedItem);
// etc
岁吢 2024-07-16 21:15:55

不,这不是所有表单变量的集合或对象(这太简单了)。

如果这就是您想要的,您可以创建一个自定义对象,如描述的大红狗(brd6644)。 但这是可选的; 在发送回对象之前,您不需要创建对象。 您可以将每个字段作为参数传递,通过它们的 ID 引用它们。 这实际上取决于偏好以及您的 CF 服务是否基于 OO。

您还可以选择创建数据模型并将其发送回 CF,如下所示:

<!-- DATA MODEL -->
<mx:Model id="formModel">
    <form>
        <beginDate>{beginDate.selectedDate}</beginDate>
        <endDate>{endDate.selectedDate}</endDate>
        <organization>
            <name></name>
            <address></address>
        </organization>
    </form>
</mx:Model>

<!-- REMOTE OBJECT/SERVER SIDE FORM HANDLER -->
<mx:RemoteObject
    id="roSubmitForm"
    source="com.mycfc"
    destination="ColdFusion"
    showBusyCursor="true">

    <mx:method name="submitForm" result="onSubmit(event)">
        <mx:arguments>
            <form>
                <beginDate>{formModel.beginDate}</beginDate>
                <endDate>{formModel.endDate}</endDate>
                <organization>
                    <name>formModel.organization.name</name>
                    <address>formModel.organization.address</address>
                </organization>
            </form>
        </mx:arguments>
    </mx:method>
</mx:RemoteObject>

以下是有关 Flex 数据模型...我仍然没有完全相信它们的用处...但这是另一种选择。

No, this isn't a collection or object for all the form variables (that would be too easy).

If that's what you want you can create a custom object like Big Red Dog described (brd6644). That's optional though; you don't need to create an object before you send it back. You could just pass each field as an argument referencing them by their Id. It really depends on preference and whether or not your CF services are OO-based.

You also have the option of creating a data model and sending that back to CF like so:

<!-- DATA MODEL -->
<mx:Model id="formModel">
    <form>
        <beginDate>{beginDate.selectedDate}</beginDate>
        <endDate>{endDate.selectedDate}</endDate>
        <organization>
            <name></name>
            <address></address>
        </organization>
    </form>
</mx:Model>

<!-- REMOTE OBJECT/SERVER SIDE FORM HANDLER -->
<mx:RemoteObject
    id="roSubmitForm"
    source="com.mycfc"
    destination="ColdFusion"
    showBusyCursor="true">

    <mx:method name="submitForm" result="onSubmit(event)">
        <mx:arguments>
            <form>
                <beginDate>{formModel.beginDate}</beginDate>
                <endDate>{formModel.endDate}</endDate>
                <organization>
                    <name>formModel.organization.name</name>
                    <address>formModel.organization.address</address>
                </organization>
            </form>
        </mx:arguments>
    </mx:method>
</mx:RemoteObject>

Here is more on Flex data models... I'm still not completely sold on their usefulness... but it's another option.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文