I’ve built this methodology for allowing the easy design and implementation of sequential bi-directional data translation using the InputFlowConnector / InputFlowTerminator interface model.
I’ve uploaded the example here: http://labs.emoten.com/projects/Juki/JKAbstractTranslatorLink/TranslatorTunnelTest.html
Note: The Easy User Input Translator does not understand AM/PM.
My first reference implementation is using the class JKTranslatorTunnel as a two-way binding mechanism with translation. Essentially it makes a 2-3 line implementation to bind your Model object to some sort of View with translation. My example is a case where the Model contains a integer property representing Military time and the view displays Standard time. I’ve also attached a user-input translator that converts shorthand input to Standard time. This comes in handy so we can translate shorthand to standard then pass the standard to the translator that will translate that into military time and update the model. At the same time it will also format the View.
The reference implementation in Flex looks like this. “in1″, “in2″ are both TextInput UIControls. JKAbstractTranslatorLink is a LinkedListEntry. To add many items into the translation link just keep on populating the “.next” or “output”.
Emoten Core Docs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | <fx:Script> <![CDATA[ import com.emoten.core.data.translators.JKEasyUserTimeInputTanslatorLink; import com.emoten.core.data.LinkedList; import com.emoten.core.data.JKAbstractTranslatorLink; import com.emoten.core.data.translators.JKMilitaryTimeTranslatorLink; import com.emoten.core.data.JKTranslatorTunnel; protected var _tunnel:JKTranslatorTunnel; public function onCompleteEvent( event:*=null ):void { var ls:JKAbstractTranslatorLink = new JKMilitaryTimeTranslatorLink(); ls.output( DirectionEnum.FORWARD, new JKEasyUserTimeInputTanslatorLink() ); _tunnel = new JKTranslatorTunnel( this.in1, "text", this.in2, "text", ls ); } ]]> </fx:Script> |