XAJA Data Binding

XAJA provides advanced support of data binding. Connections between visual and logical elements are imperative, without necessity to handling objects lifecycle and addressing elements directly from the script. Binding expressions uses it's own language, which is almost same as JavaScript, but surprisingly it is parsed and interpreted by XAJA engine. The reason is simple - binding must react to all changes of source values, regardless of how deep in expression tree is change signalized.

You don't have to setup anything else than refer to XAJA framework, understand few simple notation rules and fill XJ-BINDING attribute by some binding expression:


Each binding expression has:

If relative source is omitted, left part of expression uses "@" and right part uses "%".




Binding expression on both sides could be complex. You can call methods and also dive deep in expression tree:




We already mentioned DataContext. It is special mechanism for simplification of data binding. Each element virtually inherits DataContext from its parent until DataContext of some child element is explicitly set. As you noticed above, if Relative Source symbol is omitted in right side expression, it is by default evaluated against owners DataContext.




Keep in your mind that DataContext should not be ever set directly, but using binding or, when it is necessary, using DataContextManager:
var div = document.getElementById("div1"); Xaja.get("DataContextManager").setDataContext(div, myDatacontextObject);


At the end, few words about watching techniques. Is obvious that XAJA has to somehow watch changes of binding sources. There are three mechanisms which the system tries to apply in following order:

1.) Native JS watch
2.) FieldeEncapsulation into setter
3.) Watching interval

The decision of what mechanism will be used in each particular case, depends of borwser support and also on type of source object.





XAJA
XAJA Basics
Advanced
Contact