New to Fantom, but so far I'm loving how fast I can get up and running with fwt.
I have a question about fwt event handling and serialization. If I want to deserialize code that produces a GridPane with Labels, Textboxes, buttons etc, where should I place the event listener to keep track of when I modify those text fields, push button, etc? For example in the fwt demo, the Serialize tab lets you serialize something like this:
fwt::GridPane
{
numCols = 2
fwt::Label { text = "Name" },
fwt::Text { text = "Johnny" }
}
To narrow my question down a bit where in the context of the demo could you place an event listener to look at fields generated from serialized code, or what would be the best way to go about keeping track of user modifications. (under the assumption there could be an unknown number of fields to be modified) I tried using onModify inside of the serialized code but not sure of how to go about that properly.
brianThu 21 Jul 2011
Hi @yliu,
Welcome to Fantom and glad to hear you like Fantom.
Your question is an interesting one and I am not sure I have a suitable answer. Event handlers are funny beasts in we don't have a suitable format for serialization/deserialization since they are effectively code, not data. So as things stand now all event handlers are actually once methods, not actually serialized field (previously they were transient).
So one pragmatic option is don't actually store a serialized graph, but rather store an actual Fantom script with the handlers just defined as normal closures.
Another angle to consider is the fact that the serialization syntax does allow method literals to be used:
Originally I had some thoughts that we could use that to serialize to bind handlers to specific methods - but nothing like that is implemented at the moment.
yliu Thu 21 Jul 2011
New to Fantom, but so far I'm loving how fast I can get up and running with fwt.
I have a question about fwt event handling and serialization. If I want to deserialize code that produces a GridPane with Labels, Textboxes, buttons etc, where should I place the event listener to keep track of when I modify those text fields, push button, etc? For example in the fwt demo, the Serialize tab lets you serialize something like this:
To narrow my question down a bit where in the context of the demo could you place an event listener to look at fields generated from serialized code, or what would be the best way to go about keeping track of user modifications. (under the assumption there could be an unknown number of fields to be modified) I tried using
onModify
inside of the serialized code but not sure of how to go about that properly.brian Thu 21 Jul 2011
Hi @yliu,
Welcome to Fantom and glad to hear you like Fantom.
Your question is an interesting one and I am not sure I have a suitable answer. Event handlers are funny beasts in we don't have a suitable format for serialization/deserialization since they are effectively code, not data. So as things stand now all event handlers are actually once methods, not actually serialized field (previously they were transient).
So one pragmatic option is don't actually store a serialized graph, but rather store an actual Fantom script with the handlers just defined as normal closures.
Another angle to consider is the fact that the serialization syntax does allow method literals to be used:
Originally I had some thoughts that we could use that to serialize to bind handlers to specific methods - but nothing like that is implemented at the moment.