Child pages
  • D2W Rules Reference - Cookbook - FAQ
Skip to end of metadata
Go to start of metadata

Rule Lists

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.

For quick reference:

1. How do I make my attributes and entities editable?

100: true => isEntityEditable = true [com.webobjects.directtoweb.BooleanAssignment]

2. How do I make my relationships editable in ERD2W? (They are already are editable in D2W.)
Add two rules. This:

90: task = 'edit' and smartRelationship.isToMany = 1 => componentName = "ERD2WEditToManyFault"
      [com.webobjects.directtoweb.Assignment]

and the below:

 90: task = 'edit' and smartRelationship != null and not (smartRelationship.isToMany = 1) => componentName = "ERD2WEditToOneRelationship"
      [com.webobjects.directtoweb.Assignment]

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.
There are many possible components to choose from. These are just a couple as an example.
Add two rules. This:

90: task = 'inspect' and smartRelationship.isToMany = 1 => componentName = "ERD2WDisplayToManyList"
      [com.webobjects.directtoweb.Assignment]

and the below:

 90: task = 'inspect' and smartRelationship != null and not (smartRelationship.isToMany = 1) => componentName = "ERD2WDisplayToOne"
      [com.webobjects.directtoweb.Assignment]

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?

The key is: displayPropertyKeys. This key represents a list of attributes to display for an entity. An example rule:

100: entity.name = 'MyEntity' => displayPropertyKeys = ("attribute1","attribute2", "relationship1","relationship2.attribute3") [Assignment]

Note that you can pick attributes across relationships. You now have total control of what gets displayed.

5. If you want to use 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.

The key is: clickToOpenEnabled. This key is on ERD2WPage and controls whether clickToOpen is enabled for that specific page. An example rule:

10 : pageConfiguration like '*Excel*' => clickToOpenEnabled = false [com.webobjects.directtoweb.BooleanAssignment]

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).

100: *true* => visibleEntityNames = ("Foo","Bar","Baz","FooBar") [Assignment]

7. How do I easily use my own custom component in a Direct to Web page?

Step 1:

Add the following rules to your rule file:

100: pageConfiguration = "ListTheEntity" and propertyKey = "theProperty" => componentName = "D2WCustomComponent"
100: pageConfiguration = "ListTheEntity" and propertyKey = "theProperty" => customComponentName = "MyThePropertyComponent"

Step 2:

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.

  public EOEnterpriseObject object() {
    return (EOEnterpriseObject) valueForBinding("object");
  }

  public String key() {
    return (String) valueForBinding("key");
  }

8. How do I use features such as sections and tabs with the rules?

100: (entity.name = 'Movie' and (task = 'inspect' or task = 'edit')) => subTask = "tab"
100: (entity.name = 'Movie' and (task = 'inspect' or task = 'edit')) => tabSectionsContents = ( ("Foo", ("FooBar", "title", "category", "dateReleased"), ("FooBaz", "plotSummary", "posterName")),  ("Bar", "revenue", "studio"))

The second rule will give you:

Tabs: Foo, Bar

Sections under Foo: FooBar, FooBaz

Like:

FooBar
title
category
dateReleased

FooBaz
plotSummary
posterName

9. A simpler way to specify this stuff is:

displayPropertyKeys = ("(section11)", "key11".... "(section2)", "key21")

and

displayPropertyKeys = ("[Tab1]", "(section11)", "key11".... "[Tab2]", "(section21)", "key21")

for tab pages.

10. Changing the display name for a PageConfiguration

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.

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:

100: (pageConfiguration = 'EditMyPeople' => displayNameForPageConfiguration = "Edit My Profile"

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.

Localizable.strings
"Pages.MyDocuments" = "List My Documents!";

This entry can be used with no associated rule and it will do the right thing.

If you want to use the @@session.variable.blah@@ in your pageConfigurationNames, you'll need to use a rule with a delayed assignment.

Localizable.strings
"Pages.MyDocuments" = "List @@session.loggedInUser.fullName@@'s Documents";

Rule:
100 : pageConfiguration = 'MyDocuments' => displayNameForPageConfiguration = "Pages.MyDocuments" [ERDDelayedLocalizedAssignment]
Adding a normal component to a ModernDirectToWeb App

see Adding a Normal WOComponent Page to an ERModernLook-based application

ERExcelLook specific rules

Additional tips for ERExcelLook