Part 3: Allowing binding to missing XML nodes.
You might notice that if you try to bind to an element that does not exist in the model, you will get an error in the call to evaluate. This adds some complexity and burden so we will make a function that ensures the bound path exists in the XML DOM. Ensuring the xpath makes development much easier.
Trying to share any coding knowhow whenever I run into any issues, which is every day in the web programming world.
Saturday, December 31, 2011
Simplify with an XML data model - Part 3
Friday, December 30, 2011
Simplify with an XML data model - Part 2
Part 2: Setting the form values from XML (Bi-directional binding).
Binding should work two ways, updating the model from the form fields and updating the form fields from the model. Let’s update the code so the form is populated with data when the page is loaded.
Wednesday, December 28, 2011
Simplify with an XML data model - Part 1
Part 1: Binding from XML to the HTML form.
When doing data binding, you typically need to map a field in the UI with some part of the data model. XPath is a terrific solution to this. All you need is an XPath expression that evaluates to a single element or attribute node. This allows for bidirectional binding between HTML <form> elements and XML nodes. Binding to read-only HTML elements can be done with more complex XPath expressions and involve several nodes and functions, e.g. concatenating several fields together. It might make sense to allow for one input to map to many nodes in the future.
Interactive Example:
Interactive Example:
Monday, December 26, 2011
Simplify with an XML data model - Introduction
A system for XML data binding in the browser with XPath and client side validation using Schematron and XSLT.
Introduction
As a Java developer I find myself wondering why I spend so much time dealing with data models. For each application I work on, my time is mostly spent creating a data model in the database, a corresponding data model business object in Java code, and form value objects to collect data from web pages. Then I have to write the code that copies all the fields between models. Then there is the problem of validation rules, which require yet another framework.
After working with web services and JAXB, I started to wonder if there was an easier and more flexible way of representing all of this data in XML and skipping all the myriad Java data model classes. It turns out that XML makes for a great data model. It can represent any type of data, is easy to write, access, transform and exchange. It’s the X in AJAX for crying out loud!
Subscribe to:
Posts (Atom)