Saturday, April 21, 2007

metadata.Transient

I've never seen an authoritative source fully explain Transient, but we have a lot of things that give us the main idea. It appears data marked as Transient is ignored in many cases, mostly having to do with Flex Data Services. The short description of this tag appears to be that if you don't want a property saved or used by FDS, mark it as Transient. Here's the supporting evidence:

Peter Farland of Adobe has stated while referring to RemoteObject:
"If you're worried that you'll need to send this type back to the server and you don't want these newly added dynamic properties to be sent to the server, then [...] you could simply declare that a particular concrete property on your client type was "transient" using [Transient] metadata - these properties wouldn't be included when instances were sent back to the server." (full message here)

Additionally, Seth Hodgson of Adobe stated:
"Try tagging the properties that you don't want managed in your [Managed] AS class as [Transient]. This should prevent changes to them from being logged/committed." (full message here)

The only reference in the mx package is in mx.utils.ObjectUtil.getClassInfo(). This method returns information about a class and one of the parameters of the method defines whether or not to ignore properties marked by the Transient tag.

The docs refer the concept of transience but they do not refer to the Transient tag specifically.

*Interesting note: "transient" is a reserved word for possible future use.

2 comments:

jeremy said...

I had always been using this metatag in value object classes, it's quite useful to mark some properties as transient and they would never be sent back to the back end.

Ionut said...

" A transient variable is a variable that may not be serialized. Transient instance fields are neither saved nor restored [...]"
this is in java. it's the same in as3 -> that property won't be send to a service/backend (will not be serialized)

"Flex", "ActionScript" and possibly "MXML" are probably trademarks of Adobe Systems Incorporated.
"Adobe" is a trademark of Adobe Systems Incorporated.
This site is in no way endorsed or sponsored by Adobe Systems Incorporated.
Content Copyright © 2007 Daniel Freiman.
Site Design Copyright by its copyright holder.
The Flex Non-Docs reserves the right to remove comments for any reason.
All ActionScript and MXML code (and ONLY ActionScript and MXML code) on this website is available under the MIT License.