2008-02-10
grails flex 例子
关键字: flex grails
一个结合 flex-plugin 的例子展示
具体操作步骤
1)安装 flex plugin
2)创建一个domian Product 和service
3)在web-app目录下,新建下面3个文件
main.mxml
ProductForm
Product.as
4)直接运行程序
如下图
具体操作步骤
1)安装 flex plugin
2)创建一个domian Product 和service
class Product {
String name
String description
String image
String category
Double price
Integer qtyInStock
}
class ProductService {
static expose = ['flex-remoting']
def getProducts() {
return Product.list();
}
def update(Product product) {
def p = Product.get(product.id)
if (product) {
p.properties = product.properties
p.save()
}
}
}
3)在web-app目录下,新建下面3个文件
main.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" layout="horizontal"
creationComplete="srv.getProducts()">
<mx:RemoteObject id="srv" destination="productService"/>
<mx:Panel title="Catalog" width="100%" height="100%">
<mx:DataGrid id="list" dataProvider="{srv.getProducts.lastResult}" width="100%" height="100%"/>
</mx:Panel>
<ProductForm product="{Product(list.selectedItem)}"/>
</mx:Application>
ProductForm
<?xml version="1.0" encoding="utf-8"?>
<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*"
title="Details" width="100%" height="100%">
<Product id="product"
name="{productName.text}"
category="{category.text}"
price="{Number(price.text)}"
image="{image.text}"
description="{description.text}"/>
<mx:RemoteObject id="srv" destination="productService"/>
<mx:Form width="100%">
<mx:FormItem label="姓名">
<mx:TextInput id="productName" text="{product.name}"/>
</mx:FormItem>
<mx:FormItem label="Category">
<mx:TextInput id="category" text="{product.category}"/>
</mx:FormItem>
<mx:FormItem label="Image">
<mx:TextInput id="image" text="{product.image}"/>
</mx:FormItem>
<mx:FormItem label="Price">
<mx:TextInput id="price" text="{product.price}"/>
</mx:FormItem>
<mx:FormItem label="Description" width="100%">
<mx:TextArea id="description" text="{product.description}" width="100%" height="100"/>
</mx:FormItem>
</mx:Form>
<mx:ControlBar>
<mx:Button label="更新" click="srv.update(product);"/>
</mx:ControlBar>
</mx:Panel>
Product.as
package
{
[Bindable]
[RemoteClass(alias="Product")]
public class Product
{
public function Product()
{
}
public var id:int;
public var name:String;
public var description:String;
public var image:String;
public var category:String;
public var price:Number;
public var qtyInStock:int;
}
}
4)直接运行程序
如下图
- 17:53
- 浏览 (749)
- 评论 (4)
- 分类: grails
- 进入论坛
- 发布在 Groovy on Grails 圈子
- 相关推荐
评论
mickeyccq
2008-03-29
那些XML是可以通过Flex Builder来构建的。。。像制作传统的VB程序一样方便。
ourfirebird
2008-03-09
Flex Builder3提示出错!
jy00057800
2008-02-29
我照着你的作为什么报
[RPC Fault faultString="Send failed" faultCode="Client.Error.MessageSend" faultDetail="Channel.Connect.Failed error NetConnection.Call.Failed: HTTP: Status 404: url: 'http://localhost:6666/grails_flex/6666'"]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()
at mx.rpc::Responder/fault()
at mx.rpc::AsyncRequest/fault()
at mx.messaging::ChannelSet/faultPendingSends()
at mx.messaging::ChannelSet/channelFaultHandler()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.messaging::Channel/connectFailed()
at mx.messaging.channels::PollingChannel/connectFailed()
at mx.messaging.channels::AMFChannel/statusHandler()
这错误呢
[RPC Fault faultString="Send failed" faultCode="Client.Error.MessageSend" faultDetail="Channel.Connect.Failed error NetConnection.Call.Failed: HTTP: Status 404: url: 'http://localhost:6666/grails_flex/6666'"]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()
at mx.rpc::Responder/fault()
at mx.rpc::AsyncRequest/fault()
at mx.messaging::ChannelSet/faultPendingSends()
at mx.messaging::ChannelSet/channelFaultHandler()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.messaging::Channel/connectFailed()
at mx.messaging.channels::PollingChannel/connectFailed()
at mx.messaging.channels::AMFChannel/statusHandler()
这错误呢
山风小子
2008-02-11
很漂亮 :)
希望那些xml文件的编写也有相应的DSL,这样就有GoG的味道了 :)
多谢分享!
希望那些xml文件的编写也有相应的DSL,这样就有GoG的味道了 :)
多谢分享!
发表评论
提醒: 该博客已发表在公共论坛,博客所有留言会成为论坛回贴,留言请注意遵守论坛发贴规则
- 浏览: 14501 次
- 性别:

- 来自: 济南

- 详细资料
搜索本博客
我的相册
detail
共 1 张
共 1 张
最新评论
-
grails 导出 excel
你确认在你的controller中定义这个XlsExportService 吗 ...
-- by dellsoft -
grails 导出 excel
不能执行:java.lang.NullPointerException: Can ...
-- by ourfirebird -
jsecurity 资料
一直在关注中,其基于pojo的特性还是很诱人的.
-- by agile_boy -
extjs dwr spring
谢谢,学习,学习
-- by fang_qi -
grails 文档出来了
英文也够明白的啊,我觉得这个比其他的框架文档都要好,都很详细的,不用翻译了吧:)
-- by Fly_m






评论排行榜