Form Design Patterns
A design pattern is a recurring set of solutions to common problems, written down in such a way as to help designers apply them to new problems—avoiding the pain of having to rediscover them. The popular 1995 book Design Patterns: Elements of Reusable Object-Oriented Software (Addison-Wesley) helped make many developers aware of design patterns. Since then, many other fields, mostly computer-related, have agreed upon design patterns. The following sections describe design patterns for XForms, including the four pieces of information that Design Patterns made popular. Each pattern includes:
A problem definition
A solution description
A discussion of consequences and trade-offs
Each section also contains sample code to illustrate the pattern.
Problem: XPath expressions used by XForms can get extremely complicated, and keeping track of context nodes and other details can obscure the details of what’s happening in a form.
Solution: It is possible to author a form in such a way that the only XPath expressions used are simple names, much like the departing HTML forms technology. To do this, the structure of the user interface elements must match the structure of the instance data. Additional levels of UI nesting can be accomplished with group elements, so that instance data like this:
<purchaseOrder> <items> <item partNum="1234"> <quantity/> </item> </items> </purchaseOrder>
would have a matching user interface like this:
<group name="items"> <group ...