如何在 Flex 中将 Parsley 与 GraniteDS 结合使用?

发布于 2024-09-26 15:55:50 字数 1516 浏览 0 评论 0原文

我想使用 Parsley 框架,并且想使用 GraniteDS 进行远程处理。从 2.1 开始,GraniteDS 从 Java 代码生成 AS3 服务类作为本地代理,我想在 Parsley 中使用这些类。

我可以使用 Parsley 成功注入服务类,但是当我调用它们的任何方法时,我会得到一个空对象错误,

at org.granite.tide::Component/http://www.adobe.com/2006/actionscript/flash/proxy::callProperty()[C:\workspace_\graniteds\as3\framework\org\granite\tide\Component.as:172]
at library::BookServiceBase/get()[C:\Documents and Settings\MedLineTec\Adobe Flash Builder 4\library\src\library\BookServiceBase.as:36]

这是因为 Parsley 正在创建服务类的实例,而没有实际向它们注入相关的“上下文”来执行 GraniteDS 远程处理。我需要弄清楚如何为欧芹实例化的服务类提供 GraniteDS 上下文。我看到一个帖子欧芹论坛有人推荐:

<parsley:ContextBuilder>
      <parsley:FlexConfig type="{UserManagerConfig}"/>
      <parsley:RuntimeConfig instances="{[tideContext]}" />
</parsley:ContextBuilder>

...

[Bindable]
private var tideContext:Context = Spring.getInstance().getSpringContext(); 

但这对我不起作用。我熟悉 GraniteDS,但不熟悉 Parsley,所以也许这就是解决方案,但正确应用它超出了我的能力范围。

如果有人将其与 Swiz 或 Spring ActionScript 等其他框架配合使用,那么也请传递该解决方案,因为它可能非常相似。

更新: 我通过阅读 Granite 源代码发现,在我用 Parsley 注入服务(例如 bookService)后,如果我运行

private var tideContext:Context = Spring.getInstance().getSpringContext(); 
bookService.meta_init("bookService", tideContext);

那么我可以成功使用该服务。所以我想我只需要知道如何以一种自动的方式使用我在 Parsley 中声明的所有服务来执行此操作。

I want to use the Parsley framework and I want to use GraniteDS for remoting. As of 2.1, GraniteDS generates AS3 service classes from your Java code as local proxies, and I want to use these classes in Parsley.

I can successfully inject the service classes with Parsley but when I call any of their methods I get a null object error

at org.granite.tide::Component/http://www.adobe.com/2006/actionscript/flash/proxy::callProperty()[C:\workspace_\graniteds\as3\framework\org\granite\tide\Component.as:172]
at library::BookServiceBase/get()[C:\Documents and Settings\MedLineTec\Adobe Flash Builder 4\library\src\library\BookServiceBase.as:36]

This would be because Parsley is creating instances of the service classes without actually injecting them with the relevant "context" to do the GraniteDS remoting. I need to figure out how to give the GraniteDS context to the service classes which parsley instantiates. I saw a post on the parsley forums where someone recommended:

<parsley:ContextBuilder>
      <parsley:FlexConfig type="{UserManagerConfig}"/>
      <parsley:RuntimeConfig instances="{[tideContext]}" />
</parsley:ContextBuilder>

...

[Bindable]
private var tideContext:Context = Spring.getInstance().getSpringContext(); 

But that didn't work for me. I'm familiar with GraniteDS but not with Parsley so maybe this is the solution but applying it correctly is above my head.

If someone has it going with another framework like Swiz or Spring ActionScript then please also pass that solution on as it might be very similar.

UPDATE:
I figured out by reading the Granite source code that after I inject a service with Parsley (e.g. bookService), if I run

private var tideContext:Context = Spring.getInstance().getSpringContext(); 
bookService.meta_init("bookService", tideContext);

Then I can successfully use the service. So I guess I just need to know how to do this in a sort of automatic way with all the services I declare in Parsley.

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

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

发布评论

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

评论(1

妖妓 2024-10-03 15:55:50

我会看一下 Pimento 而不是 GraniteDS。它也是一个 SpiceFactory ActionScript 库,就像 Parsley 一样

I'd take a look at Pimento instead of GraniteDS. It's a SpiceFactory ActionScript library too, like Parsley

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