Wiki source code of How to Write D2W Rules

Last modified by Ravi Mendis on 2009/11/12 16:52

Hide last authors
Ravi Mendis 1.1 1 The quick answer is...
2
3 == Use Convention Over Configuration ==
4
Ravi Mendis 6.1 5 We may use [[convention over configuration>>url:http://en.wikipedia.org/wiki/Convention_over_configuration||shape="rect"]] to set up **default** D2W rules.
Ravi Mendis 1.1 6
7 In D2W, rules with a higher priority take precedence.
Ravi Mendis 6.1 8 e.g:
Ravi Mendis 1.1 9
10 {{code}}
11
12 100: entity.name = 'Father' and task = 'edit' and propertyKey = 'firstName' => componentName = "D2WEditString"
13
14 {{/code}}
15
16 The above will override, or take precedence over the following:
17
18 {{code}}
19
20 75: task = 'edit' and propertyKey = 'firstName' => componentName = "D2WEditString"
21
22 {{/code}}
23
24 We may exploit this feature of D2W to set up a set of rules as conventions or defaults.
Ravi Mendis 6.1 25 As an example, the above rule may be set up to be a default for the editing of the key {{code language="none"}}firstName{{/code}} instead of having to define separate rules for every entity that has a {{code language="none"}}firstName{{/code}}. In other words you may define the one rule (above) instead of the following three rules:
Ravi Mendis 1.1 26
27 {{code}}
28
29 100: entity.name = 'Father' and task = 'edit' and propertyKey = 'firstName' => componentName = "D2WEditString"
30 100: entity.name = 'Mother' and task = 'edit' and propertyKey = 'firstName' => componentName = "D2WEditString"
31 100: entity.name = 'Child' and task = 'edit' and propertyKey = 'firstName' => componentName = "D2WEditString"
32
33 {{/code}}
34
35 In this manner we can keep the number of D2W rules down to a minimum - which vastly improves maintainability.
36
37 {{info title="Rule of Thumb"}}
38 Set a lower priority to generic rules.
39 {{/info}}