incubator-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Incubator Wiki] Update of "xap/CodeTour" by jmargaris
Date Thu, 22 Mar 2007 08:57:51 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Incubator Wiki" for change notification.

The following page has been changed by jmargaris:
http://wiki.apache.org/incubator/xap/CodeTour

------------------------------------------------------------------------------
   * ''bridges/basic/AbstractWidgetBridge.js'' - This is the base class for all bridges that
map to UI widgets. It handles basic attributes like '''x''', '''y''' and '''color''' in a
reasonable default fashion.
   * ''bridges/dojo/DojoWidgetBridge.js'' - This is the base class for widgets based on the
Dojo framework.
  
+ === TextFieldBridge - An Example Dojo Widget Bridge ===
+ ''bridges/dojo/TextFieldBridge.js'' is a good example of a medium complexity bridge class.
It does the following:
+  *Supports basic common attributes like position and coloring.
+  *Supports text-specific attributes like '''text''','''maxLength''' and '''editable'''
+  *Fires events and updates the XML DOM when the text in the onscreen widget is changed.
+ 
+ Supporting common attributes comes for free by extending DojoWidgetBridge. Supporting new
attributes is a two step process:
+  *Override '''getNewAllowedAttributes()''' to supply a list of attributes specific to this
widget that we recognize.
+  *For each attribute, write a method in the form of '''setTextAttribute()''' or '''setMaxLengthAttribute'''
where the middle word(s) of the function name is the attribute.
+ You can see that in the TextFieldBridge '''setTextAttribute()''' takes the argument, which
is the new value of the '''text''' attribute, and passes it to a function on the widget itself
that does the work. '''setMaxLengthAttribute()''' also calls a function on the widget but
does some extra work to truncate the existing text if it is currently too long.
+ 
+ Supporting events is done in TextFieldBridge by using '''dojo.event.connect()''' to listen
for keyup, textchange and mouseout on the underlying widget. When the underlying widget receives
a keyup the '''onTextChange()''' method in TextFieldBridge is called. This method checks to
make sure the text has actually changed and if so updates the text in the XML DOM using '''writeBackAttribute()'''
and fires an event using '''fireEvent()''', two methods provided by the base class.
+ 

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@incubator.apache.org
For additional commands, e-mail: cvs-help@incubator.apache.org


Mime
View raw message