Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

In this case, the qualifier is always true, so long as no other rule priority is greater than 100, the pageWrapperName key in the D2WContext will always equal "PageWrapper". The assignment being used is the simple Assignment class, so the string in 'value' is assigned directly to 'keypath.' And since the D2WContext implements NSKeyValueCodingAdditions, you can reference this keyPath in a d2w component using a wod binding like:

No Format

PageWrapper : WOSwitchComponent {
	componentName = d2wContext.pageWrapperName;
}

...

ERDAssignment caches values using the ERDComputingAssignmentInterface. That interface defines one method: dependentKeys(). The dependentKeys method takes one string argument representing a keyPath. The return value is an array of keyPaths that will change the outcome of the Assignment value to keyPath. In this way, the Wonder rule system allows for 'significant' keys to be assigned on a per keyPath basis. So, for example, if you create a custom assignment for the 'look' key and the value needs to be re-evaluated based on the current user, then your dependentKeys() method might look something like:

No Format

public NSArray dependentKeys(String keyPath) {
    if("look".equals(keyPath)) {
        return new NSArray(new String[] {"session.user"});
    }
    return NSArray.emptyArray();
}

...

Your method that handles the assignment would look like:

No Format

public Object myKeyPath(D2WContext d2wContext) {
    // Logic goes here to apply a value to the key named by keyPath()
}

In this way, you can define the logic for individual keys separately. This allows you to use a single assignment to resolve values for multiple keyPaths without resorting to a large if/else block. You can extend this behavior further by overriding the keyForMethodLookup() method. If you override this method and return value() for instance, it would then assign a value to your key with a method by the same name as your value.

No Format

public Object someValue(D2WContext d2wContext) {
    // Logic goes here to apply a value to the key named by keyPath()
}

...

You can turn on rule tracing in the console using -D2WTraceRuleFiringEnabled YES in your run/debug configurations. To get more detailed information, you can use Wonder's rule system logging instead.

Apple's D2W documentation
rule modeler
Configuring Rule Modeler