浏览 1444 次
|
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
|---|---|
| 作者 | 正文 |
|
时间:2008-02-10 关键字: flex grails
一个结合 flex-plugin 的例子展示
具体操作步骤 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)直接运行程序 如下图 声明:JavaEye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
|
|
| 返回顶楼 | |
|
时间:2008-02-11
很漂亮 :)
希望那些xml文件的编写也有相应的DSL,这样就有GoG的味道了 :) 多谢分享! |
|
| 返回顶楼 | |
|
时间: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() 这错误呢 |
|
| 返回顶楼 | |
|
时间:2008-03-09
Flex Builder3提示出错!
|
|
| 返回顶楼 | |
|
时间:2008-03-29
那些XML是可以通过Flex Builder来构建的。。。像制作传统的VB程序一样方便。
|
|
| 返回顶楼 | |







