All the forms in the Swing user interface follow the Model-View-Controller (MVC) paradigm. The form itself acts as the View, so it only has presentation logic. All the business logic is in a separate Controller class. The model for every form is an XML-DOM Element.
To further simplify the presentation logic, the core classes in <yfs> support a form of XMLBinding of different types of controls to the DOM model. This enables the form designer to bind the different controls on a form to different parts of the DOM. At run-time the infrastructure keeps the DOM and the controls synchronized. When the DOM is changed the changes are reflected on the control, and the reverse is true as well.
The binding semantics control are described in detail below.
Given an input XML, parts of the XML can be bound to controls based on an XMLBindingString. Each string is evaluated in XSL syntax and the first match is used as the value of the binding.
Assume the bound XML is the following:
<Order OrderNo='23' OrderDate='20010101' >
<ShipToAddress City='Nashua' />
</Order>
The following table illustrates the XMLBinding.
XML Binding String | Example Value |
---|---|
Xml:/Order/@OrderNo | 23 |
Xml:/Order/@OrderDate | 20010101 |
Xml:/Order/ShipToAddress/@City | Nashua |
Xml:/Order/ShipToAddress | Evaluates to the ShipToAddress Node |
Every Swing control has a bean property name that can be set by using the setName(String) function. The value of this property should be an XMLBindingString that specifies the XMLData that is to be bound to that control.
In addition to the Name property, the following JTextField properties can be set for any text field:
Property | Syntax |
---|---|
Data Type Only Integer, Date and String are supported |
|
Associated Label This is the JLabel associated with the text field |
|
Mandatory If Mandatory property is set to "true" and the field is left blank, the label associated with the text field changes color. This is triggered on the lostfocus event of the text field. |
|