[snow-cvs] r12 - in trunk: docs src/lisp/snow

Alessio Stalla astalla at common-lisp.net
Tue Oct 27 21:36:24 UTC 2009


Author: astalla
Date: Tue Oct 27 17:36:21 2009
New Revision: 12

Log:
Updated tutorial.


Modified:
   trunk/docs/tutorial.html
   trunk/src/lisp/snow/data-binding.lisp

Modified: trunk/docs/tutorial.html
==============================================================================
--- trunk/docs/tutorial.html	(original)
+++ trunk/docs/tutorial.html	Tue Oct 27 17:36:21 2009
@@ -186,7 +186,24 @@
 (defvar *presentation-model* (new "my.presentation.Model"))
 (text-field :text (make-bean-data-binding *presentation-model* "myProperty"))
 </pre>
-You can tune the presentation model with additional arguments to <code>make-bean-data-binding</code>; for example, you can obtain a buffered model with <code>:buffered-p t</code>.</li>
+The presentation model acts as a glue between the GUI and the application logic, and provides advanced functionality (e.g. it lets you control when to synchronize the state). You can tune it with additional arguments to <code>make-bean-data-binding</code>; for example, you can obtain a buffered model with <code>:buffered-p t</code>.</li>
+<li><b>Binding to a bean property</b>, arbitrarily nested. Syntax: <code>(make-property-data-binding <bean> <property path>)</code><br />This is a convenient way to adapt a pre-existing bean with the binding framework. It connects a property path, which can be expressed in "dot notation"; to properly observe changes, every object which is part of the path must support the standard Java Bean facility for listening to property changes. Example:
+<pre class="paste-area">
+(defvar *x* (new "Person"))
+(text-field :text (make-property-data-binding *x* "address.street"))
+</pre></li>
+<li><b>Binding to a Cells-powered slot</b> of a CLOS object. Syntax: <code>(make-slot-data-binding <object> <slot-accessor-name>)</code><br />You can use this kind of binding to connect a widget property to a slot of a CLOS object using the Cells dataflow library. Example:
+<pre class="paste-area">
+(defvar *x* (make-instance 'my-class :my-slot (c-in 42)))
+(text-field :text (make-slot-data-binding *x* 'my-slot-accessor))
+</pre></li>
+<li><b>Binding to a calculated expression</b> using Cells. Syntax: <code>(make-cells-data-binding <expression> [writer])</code><br />This is useful to bind a widget to a quick-and-dirty Cells expression without creating a class instance specifically to hold it in a slot. You can optionally provide a writer function so that the widget will be able to alter the value of the expression when its value changes. Example:
+<pre class="paste-area">
+(defvar *x* (make-instance 'my-class :slot (c-in 42)))
+(text-field :text (make-cells-data-binding
+                    *x* (c? (* 2 (my-slot *x*)))
+                    (lambda (new-value) (setf (my-slot *x*) new-value))))
+</pre></li>
 
 </ul>
 <a name="more" /><h3>What's more?</h3>

Modified: trunk/src/lisp/snow/data-binding.lisp
==============================================================================
--- trunk/src/lisp/snow/data-binding.lisp	(original)
+++ trunk/src/lisp/snow/data-binding.lisp	Tue Oct 27 17:36:21 2009
@@ -128,7 +128,7 @@
 
 ;;For EL data bindings we reuse simple-data-binding, since its 'variable' can
 ;;really be any JGoodies ValueModel
-(defun make-el-data-binding (obj path)
+(defun make-property-data-binding (obj path)
   (make-instance 'simple-data-binding
 		 :variable (new "snow.binding.BeanPropertyPathBinding"
 				obj (apply #'jvector "java.lang.String" path))))
@@ -138,7 +138,7 @@
 	 (obj (funcall *bean-factory* (car splitted-expr)))
 	 (path (cdr splitted-expr)))
     (if path
-	(make-el-data-binding obj path)
+	(make-property-data-binding obj path)
 	(make-simple-data-binding (make-var obj)))))
 
 (defreadtable snow:syntax




More information about the snow-cvs mailing list