Created
April 7, 2016 07:37
-
-
Save webskin/957f4f80ff69c6a9b764513b35ce9c77 to your computer and use it in GitHub Desktop.
dto2fx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Java-To-ActionScript DTO Generation | |
| To serialize the data between Flex and Java BlazeDS expects to have the matching pairs of Flex and Java DTOs. Just add the @FXClass annotation above your Java class definition, and CDB will generate a corresponding ActionScript class and will keep it in sync with its Java peer: | |
| . . . | |
| import com.farata.dto2fx.annotations.FXClass; | |
| @FXClass(kind=FXClassKind.REMOTE) | |
| public class Company implements Serializable { | |
| . . . | |
| The corresponding ActionScript class will implement IPropertyChangeNotifier interface, dispatching PropertyChangeEvent on every update of every property, which is crucial for collection state tracking. | |
| :!: If a class depends on other classes, you need to annotate all of them with @FXClass. If you don't want a class variable to be serialized to ActionScript, annotate it with @FXIgnore. If you do not want a particular superclass or interface to be serialized you should list them in ignoreSuperClasses parameter. | |
| :!: Any un-annotated dependency class leads to compile-time error “Unsupported type: class fullyQualifiedClassNameOfTheProperty is not annotated with @FXClass” | |
| What Gets Generated from a Java Class Annotated with @FXClass | |
| In compliance with the generation gap design pattern Clear Data Builder creates two classes for every Java class annotated with @FXClass: one class extends another. The ancestor class is regenerated on every pass of CDB to be in sync with the changes of the original Java class. The descendant class, once created in the file system, is never regenerated: it is preserved for custom modifications by the developer. The table below illustrates this assuming the name of the annotated Java class is clear.samples.entity.Company: | |
| Java Class Generated ActionScript Class Regenerated | |
| clear.samples.entity.Company clear.samples.entity.generated._CompanyDTO yes | |
| clear.samples.entity.CompanyDTO no | |
| :!: To force CDB into regeneration of the descendant class, delete the existing one from your hard drive and perform Project > Clean. | |
| What Happens When An @FXClass Class Is Deleted | |
| CDB follows “I cook, you clean” principle: when you delete or rename a Java class annotated with @FXClass, CDB does absolutely nothing. In particular it does not delete the generated ActionScript classes. | |
| clearwiki/20.cleardatabuilder/03.authoring_java_dto/03.one-way_java-actionscript_dto_sync_with_fxclass_annotation.txt · Last modified: 2011/07/13 12:45 (external edit) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment