D2W Rules Reference - Cookbook - FAQ

Version 90.1 by Johan Henselmans on 2011/04/19 14:43
Warning
For security reasons, the document is displayed in restricted mode as it is not the current version. There may be differences and errors due to this.

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?

Unknown macro: noformat. Click on this message for details.

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

Unknown macro: noformat. Click on this message for details.

and the below:

Unknown macro: noformat. Click on this message for details.

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:

Unknown macro: noformat. Click on this message for details.

and the below:

Unknown macro: noformat. Click on this message for details.

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:

Unknown macro: noformat. Click on this message for details.

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

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

Unknown macro: noformat. Click on this message for details.

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

Unknown macro: noformat. Click on this message for details.

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:

Unknown macro: noformat. Click on this message for details.

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?

Unknown macro: noformat. Click on this message for details.

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:

Unknown macro: noformat. Click on this message for details.

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:

Unknown macro: noformat. Click on this message for details.

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.

Unknown macro: noformat. Click on this message for details.

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.

Unknown macro: noformat. Click on this message for details.

Adding a normal component to a ModernDirectToWeb App

Suppose you have a component somewhere that you would like to use to a direct To Web App as an extra option, under the tab section. How do get this component to work with the rest of the Direct To Web App?

The way to do this is described in some mails , but it took me some time to understand all the intricacies, so here it goes: 

We have a component HelloWorld, that consist of the following contents:

Unknown macro: color. Click on this message for details.

Unknown macro: color. Click on this message for details.
Unknown macro: color. Click on this message for details.

What is your name?Unknown macro: color. Click on this message for details.
Unknown macro: color. Click on this message for details.
Unknown macro: color. Click on this message for details.
Unknown macro: color. Click on this message for details.
Unknown macro: color. Click on this message for details.
Unknown macro: color. Click on this message for details.

Unknown macro: color. Click on this message for details.

Unknown macro: color. Click on this message for details.
Unknown macro: color. Click on this message for details.
Unknown macro: color. Click on this message for details.
Unknown macro: color. Click on this message for details.
Unknown macro: color. Click on this message for details.

Unknown macro: color. Click on this message for details.

Unknown macro: color. Click on this message for details.
Unknown macro: color. Click on this message for details.

Unknown macro: color. Click on this message for details.

Unknown macro: color. Click on this message for details.
Unknown macro: color. Click on this message for details.
Unknown macro: color. Click on this message for details.
Unknown macro: color. Click on this message for details.
Unknown macro: color. Click on this message for details.

Unknown macro: color. Click on this message for details.

 Unknown macro: color. Click on this message for details.
Unknown macro: color. Click on this message for details.
Unknown macro: color. Click on this message for details.
Unknown macro: color. Click on this message for details.
Unknown macro: color. Click on this message for details.
Unknown macro: color. Click on this message for details.

Unknown macro: color. Click on this message for details.

Unknown macro: color. Click on this message for details.
Unknown macro: color. Click on this message for details.


Unknown macro: color. Click on this message for details.

 com.webobjects.appserver.WOContext;

Unknown macro: color. Click on this message for details.

 er.extensions.components.ERXComponent;

Unknown macro: color. Click on this message for details.

 Unknown macro: color. Click on this message for details.
HelloWorld Unknown macro: color. Click on this message for details.
ERXComponent {

 Unknown macro: color. Click on this message for details.
String Unknown macro: color. Click on this message for details.
;

 Unknown macro: color. Click on this message for details.
Unknown macro: color. Click on this message for details.
Unknown macro: color. Click on this message for details.
Unknown macro: color. Click on this message for details.

 Unknown macro: color. Click on this message for details.
HelloWorld(WOContext context) {

        Unknown macro: color. Click on this message for details.
(context);

 }

 Unknown macro: color. Click on this message for details.
ERXComponent fixUserName() {

 Unknown macro: color. Click on this message for details.

    HelloWorld aPage = (HelloWorld) pageWithName(Unknown macro: color. Click on this message for details.
);

 Unknown macro: color. Click on this message for details.
Unknown macro: color. Click on this message for details.

Unknown macro: color. Click on this message for details.

 Unknown macro: color. Click on this message for details.
Unknown macro: color. Click on this message for details.
Unknown macro: color. Click on this message for details.
Unknown macro: color. Click on this message for details.
Unknown macro: color. Click on this message for details.

Unknown macro: color. Click on this message for details.

 Unknown macro: color. Click on this message for details.

 aPage.setUsername(newUserName);

 Unknown macro: color. Click on this message for details.
aPage;

 }

 Unknown macro: color. Click on this message for details.
String username() {

 Unknown macro: color. Click on this message for details.
Unknown macro: color. Click on this message for details.
Unknown macro: color. Click on this message for details.

 }

 Unknown macro: color. Click on this message for details.
Unknown macro: color. Click on this message for details.
setUsername(String username) {

 Unknown macro: color. Click on this message for details.
.Unknown macro: color. Click on this message for details.
= username;

 }

 Unknown macro: color. Click on this message for details.
String userNameExtended() {

 Unknown macro: color. Click on this message for details.
Unknown macro: color. Click on this message for details.
Unknown macro: color. Click on this message for details.

 }

 Unknown macro: color. Click on this message for details.
Unknown macro: color. Click on this message for details.
setUserNameExtended(String userNameExtended) {

 Unknown macro: color. Click on this message for details.
.Unknown macro: color. Click on this message for details.
= userNameExtended;

 }

 }

Normally, this Component will pickup a username, and will create a correct user name. 

Now suppose we want to make this component a Direct To Web Component. 

First I will do the obvious:

I will add the component to the NavigationList:

 {

 name = Root;

 children = ("Home","HelloWorld");

 },

 {

 name = "HelloWorld";

 action = "HelloWorld";

 },

 {

 name = "Home";

 action = "session.navController.homeAction";

 }

First insert/copy  this component from your normal App to the Modern Direct To Web App. Next you have to make sure that the component will follow the normal flow of a Direct To Web App. The way to accomplish this is to refactor the ERXComponent or WOComponent by a ERD2WPage or D2WPage. This will make sure that the component gets the d2wcontext, that every D2WPage needs. 

Next we add the page to the navigation menu, to the navigation controller and the rules in user.d2wmodel of our application 

Finally, we make sure that every component call gets replaced by a D2W.Factory call

HelloWorld aPage = (HelloWorld)  D2W.factory().pageForConfigurationNamed(Unknown macro: color. Click on this message for details.
, session());

Unknown macro: color. Click on this message for details.

 aPage;

instead of 

ERExcelLook specific rules

Additional tips for ERExcelLook