Difference between revisions of "JFace Data Binding/DOM"

From Eclipsepedia

Jump to: navigation, search
(DOM binding sample)
(DOM binding sample)
Line 40: Line 40:
 
</ul>
 
</ul>
  
 +
DOMObservables is used to create IObservableValue or IObservableList
 +
DOM Node implementation to manage DOM binding.
 +
 +
Here the code used to bind attribute value of DOM Element input with Text property of SWT Text :
 +
 +
<pre>
 +
// HTML : <input value="bla bla bla"... >
 +
// Bind Attribute value of DOM Element input with Text property of
 +
// SWT Text.
 +
Text text = new Text(composite, SWT.BORDER);
 +
context.bindValue(SWTObservables.observeText(text, SWT.Modify),
 +
DOMObservables.observeAttrValue(realm, textElement, "value"),null, null);
 +
 +
</pre>
  
 
[[Category:Data Binding]]
 
[[Category:Data Binding]]

Revision as of 18:37, 1 August 2008

JFace Data Binding
Home
How to Contribute
FAQ
Snippets
Concepts
Binding
Converter
Observable
Realm

Target

Work is underway to support binding to w3c DOM node. See (for the moment) TK-UI SVN - you can find two plug-in project that provides DOM-based observables :

DOM binding sample

The TestHTMLInputText DOM binding sample explains how bind this XHTML content :

<html>
  <title>DOM Bindings - HTML Input Text Sample.</title>
  <label>This sample bind :
* CharacterData of DOM Element title with Text property of SWT Shell. 
* CharacterData of DOM Element label with Text property of SWT Label. 
* Attribute value of DOM Element input with Text property of SWT Text. 
* DOM Document content with Text property of SWT Text (Area).</label>
  <input type="text" value="bla bla bla" />	
</html>

with several SWT UI widgets :

TestHTMLInputText.JPG

This screen show the result of binding between the XHTMl DOM Document and SWT UI widgets.

This sample is DOM IObservableValue implementation. It bind:

  • CharacterData of DOM Element title with Text property of SWT Shell.
  • CharacterData of DOM Element label with Text property of SWT Label.
  • Attribute value of DOM Element input with Text property of SWT Text.
  • DOM Document content with Text property of SWT Text (Area).

DOMObservables is used to create IObservableValue or IObservableList DOM Node implementation to manage DOM binding.

Here the code used to bind attribute value of DOM Element input with Text property of SWT Text :

// HTML : <input value="bla bla bla"... >
// Bind Attribute value of DOM Element input with Text property of
// SWT Text.
Text text = new Text(composite, SWT.BORDER);
context.bindValue(SWTObservables.observeText(text, SWT.Modify),
	DOMObservables.observeAttrValue(realm, textElement, "value"),null, null);