Initially, we tried to limit the scope to just the UI components and the generation of html nodes, but for most components to be usable, we included basic data binding.


In general, data binding is automatic - see the basic form example - http://lightningdart.com/exampleForm.html

You just get the data from the "DRecord" (details below).


For Data Binding, we use Protocol Buffers. Protocol buffers are a language-neutral, platform-neutral extensible mechanism for serializing structured data and very efficient + performant.  The protocol buffer generated classes are all prefixed with "D" and have just get/set methods.


The data classes are

  

DRecord -- record data
- DEntry -- data entry = column value

  

As these classes only provide get/set methods, we provided a functionality wrapper

 

DataRecord -- functionality wrapper for DRecord

 

The optional main meta classes are

 

DTable -- table definition
- DColumn -- column level info

 

The main input presentation classes are

 

EditorI -- API definition
- LEditor -- Defines Layout
  - Checkbox -- label part of field 
  - LEditorStd -- Layout with label and field
    - LInput -- input based editor
    - LSelect -- list selection
    - LLookup -- selection

 

The structural modes are

  

LComponent -- maintains "element" as well as id auto numbering and theming
- CDiv -- a <div> utility class with some composition functionality
- The Lightning components, e.g. LButton, LTable, ....

  


EditorI - the base class for data entry elements


Defines the general editor API regardless of kind (input, select, lookup, ...) or presentation (e.g. checkbox, radio).

 

String get value;
void set value (String newValue);

 

and manages value changes via

 

String get valueOriginal{}
void set valueOriginal (String newValue){}
String get defaultValue;
void set defaultValue (String newValue);
bool get changed{}

 

as well as validation - and the difference between value and display (based on "value-label" e.g. id, lookup) 

 

bool get valueRendered; // is it a lookup?
String get valueDisplay; // get the current display value
String render(String newValue, bool setValidity);

 


The value


The editor value is always a string/text. For non text based input is is normalized:

  • lookups, selects, etc.: the value (vs. display)
  • date/time: time in ms as string (to avoid localization issues and to easily display it for different timezones)  
  • numbers: with decimal point, no commas (formatted based on currency precision and locale)
  • duration: xml duration format
The editor maintains the meta data via the class DColumn - if you do not provide it it is automatically created and you can use the normal setter/getter to defined the functionality/behaviour of the editor, e.g. required, readOnly, etc.

The DColumn is also the source for label, help ... or you can set it explicitly for the editor.

After the user entered the information, you retrieve it from the Form or grid via the DataRecord wrapper or directly DRecord and DEntry. You then can use the binary Protocol Buffers serialization to transfer to servers, etc.