Version 97.1 by Johan Henselmans on 2011/04/20 04:04

Show last authors
1 === Rule Lists ===
2
3 Below are some commonly used rules and information on keys which control D2W templates. You may wish to keep your own library of commonly used D2W rules, something like "D2WRuleLibrary.d2wmodel", which can then be used to copy and paste rules into your projects.
4
5 ==== For quick reference: ====
6
7 ~1. How do I make my attributes and entities editable?
8
9 {{noformat}}
10
11 100: true => isEntityEditable = true [com.webobjects.directtoweb.BooleanAssignment]
12
13
14 {{/noformat}}
15
16 2. How do I make my relationships editable in ERD2W? (They are already are editable in D2W.)
17 Add two rules. This:
18
19 {{noformat}}
20
21 90: task = 'edit' and smartRelationship.isToMany = 1 => componentName = "ERD2WEditToManyFault"
22 [com.webobjects.directtoweb.Assignment]
23
24
25 {{/noformat}}
26
27 and the below:
28
29 {{noformat}}
30
31 90: task = 'edit' and smartRelationship != null and not (smartRelationship.isToMany = 1) => componentName = "ERD2WEditToOneRelationship"
32 [com.webobjects.directtoweb.Assignment]
33
34
35 {{/noformat}}
36
37 3. Similarly how do I make my relationships display nicely in an Inspect page in ERD2W? By default they show up as an array fault.
38 There are many possible components to choose from. These are just a couple as an example.
39 Add two rules. This:
40
41 {{noformat}}
42
43 90: task = 'inspect' and smartRelationship.isToMany = 1 => componentName = "ERD2WDisplayToManyList"
44 [com.webobjects.directtoweb.Assignment]
45
46
47 {{/noformat}}
48
49 and the below:
50
51 {{noformat}}
52
53 90: task = 'inspect' and smartRelationship != null and not (smartRelationship.isToMany = 1) => componentName = "ERD2WDisplayToOne"
54 [com.webobjects.directtoweb.Assignment]
55
56
57 {{/noformat}}
58
59 4. I don't like the defaults for attributes that D2W chooses. Sometimes it chooses wisely, but not always. How do I change what gets displayed for an entity's attributes?
60
61 The key is: displayPropertyKeys. This key represents a list of attributes to display for an entity. An example rule:
62
63 {{noformat}}
64
65 100: entity.name = 'MyEntity' => displayPropertyKeys = ("attribute1","attribute2", "relationship1","relationship2.attribute3") [Assignment]
66
67
68 {{/noformat}}
69
70 Note that you can pick attributes across relationships. You now have total control of what gets displayed.
71
72 5. If you want to use [[doc:Click to Open]] for your D2W project, you'll need to disable it when you are generating ERExcelLook pages or the resulting Excel file will be unreadable gibberish.
73
74 The key is: clickToOpenEnabled. This key is on ERD2WPage and controls whether clickToOpen is enabled for that specific page. An example rule:
75
76 {{noformat}}
77
78 10 : pageConfiguration like '*Excel*' => clickToOpenEnabled = false [com.webobjects.directtoweb.BooleanAssignment]
79
80
81 {{/noformat}}
82
83 6. How do I control the list of visible Entities in my PageWrapper? My select entity popup is showing entities I don't want to be visible (ERAttachment, Lookup values, etc).
84
85 {{noformat}}
86
87 100: *true* => visibleEntityNames = ("Foo","Bar","Baz","FooBar") [Assignment]
88
89
90 {{/noformat}}
91
92 7. How do I easily use my own custom component in a Direct to Web page?
93
94 Step 1:
95
96 Add the following rules to your rule file:
97
98 {{noformat}}
99
100 100: pageConfiguration = "ListTheEntity" and propertyKey = "theProperty" => componentName = "D2WCustomComponent"
101 100: pageConfiguration = "ListTheEntity" and propertyKey = "theProperty" => customComponentName = "MyThePropertyComponent"
102
103
104 {{/noformat}}
105
106 Step 2:
107
108 Create a component in your project named 'MyThePropertyComponent' and give it an 'object' and 'key' binding. The object will receive the current object, and the key will receive the current propertyKey (as a string) from DirectToWeb. Do with them what you will.
109
110 {{code}}
111
112 public EOEnterpriseObject object() {
113 return (EOEnterpriseObject) valueForBinding("object");
114 }
115
116 public String key() {
117 return (String) valueForBinding("key");
118 }
119
120 {{/code}}
121
122 8. How do I use features such as sections and tabs with the rules?
123
124 {{noformat}}
125
126 100: (entity.name = 'Movie' and (task = 'inspect' or task = 'edit')) => subTask = "tab"
127 100: (entity.name = 'Movie' and (task = 'inspect' or task = 'edit')) => tabSectionsContents = ( ("Foo", ("FooBar", "title", "category", "dateReleased"), ("FooBaz", "plotSummary", "posterName")), ("Bar", "revenue", "studio"))
128
129
130 {{/noformat}}
131
132 The second rule will give you:
133
134 Tabs: Foo, Bar
135
136 Sections under Foo: FooBar, FooBaz
137
138 Like:
139
140 FooBar
141 title
142 category
143 dateReleased
144
145 FooBaz
146 plotSummary
147 posterName
148
149 9. A simpler way to specify this stuff is:
150
151 {{noformat}}
152
153 displayPropertyKeys = ("(section11)", "key11".... "(section2)", "key21")
154
155 and
156
157 displayPropertyKeys = ("[Tab1]", "(section11)", "key11".... "[Tab2]", "(section21)", "key21")
158
159 for tab pages.
160
161 {{/noformat}}
162
163 10. Changing the display name for a PageConfiguration
164
165 You may want to use a Page Configuration Name that is consistent with the rules for your application (uses an EntityName), but it looks weird when it is parsed for display in the default way.
166
167 For example, in Bugtracker there is a page configuration named "EditMyPeople" which makes perfect sense for the rules, but not too much as an "Edit My Profile" page. The easy way around it is:
168
169 {{noformat}}
170
171 100: (pageConfiguration = 'EditMyPeople' => displayNameForPageConfiguration = "Edit My Profile"
172
173
174 {{/noformat}}
175
176 However, it is better practice to get labels out of the rules altogether unless you want to make use of variables inside them. You put labels in your Localizable.strings file. If you just want plain text, no rule is necessary. For the following examples, "MyDocuments" is the pageConfigurationName.
177
178 {{noformat}}
179
180 Localizable.strings
181 "Pages.MyDocuments" = "List My Documents!";
182
183 {{/noformat}}
184
185 This entry can be used with no associated rule and it will do the right thing.
186
187 If you want to use the @@session.variable.blah@@ in your pageConfigurationNames, you'll need to use a rule with a delayed assignment.
188
189 {{noformat}}
190
191 Localizable.strings
192 "Pages.MyDocuments" = "List @@session.loggedInUser.fullName@@'s Documents";
193
194 Rule:
195 100 : pageConfiguration = 'MyDocuments' => displayNameForPageConfiguration = "Pages.MyDocuments" [ERDDelayedLocalizedAssignment]
196
197 {{/noformat}}
198
199 ====== Adding a normal component to a ModernDirectToWeb App ======
200
201 seeĀ [[doc:Adding a Normal WOComponent Page to an ERModernLook-based application]]
202
203 ==== **ERExcelLook specific rules** ====
204
205 [[doc:Additional tips for ERExcelLook]]