How can I add a namespace to valueObjects using FlashBuilder
When I use FlashBuilder to connect to a remote Java object using BlazeDS, FlashBuilder automatically creates a local valueObject matching the object in the remote server.
However, the package name of th开发者_JS百科e remote object gets lost in translation.
Hence if I have two remote Java objects com.foo.A and com.bar.A, I won't be able to distinguish between them in Flex. So I end up having to name my remote classes com.foo.AFoo, com.bar.ABar.
Is there a better way?
I don't see why you you can't used com.foo.A on the flex end as well as the java end. Personally, I think Flex project structure is very different from Java (for instance, Java likes to use DTO naming, while Flex uses Model) and this is why I use RemoteClass metadata to bind the Java DTO to a Flex model.
The Flex class name is not important, and is ignored when sending / receiving classes to / from BlazeDS.
What is important is the name that's specified in the [RemoteClass]
metadata on your Flex class.
Eg:
// Actionscript class Apple.as
package com.mangofactory.sample
{
[RemoteClass(alias="org.orchard.Orange")]
public class Apple {
... etc ....
Here, the Actionscript class com.mangofactory.sample.Apple
is mapped to the Java class org.orchard.Orange
While the naming of the fields & properties within the class is important, the actual class mapping is specified explicitly using Metadata.
精彩评论