User's Manual

Chapter 8. WAF Application Development Tutorial 53
/**
* Removes <code>note</code> from the set of notes tracked by this
* <code>Binder</code>.
*
* @param note The <code>Note</code> to remove
*/
public void removeNote(final Note note) {
Assert.exists(note, Note.class);
if (s_log.isDebugEnabled()) {
s_log.debug("Removing note " + note + " from " + this);
}
remove(NOTES, note);
}
public final String getContextPath() {
return "/binder";
}
}
Example 8-3. binder/src/com/example/binder/Binder.java
The BASE_DATA_OBJECT_TYPE string specifies what PDL-defined object type this domain object
corresponds to.
The getBaseDataObjectType() method makes the runtime data object type of Binder accessible
to WAF persistence.
The DataObject constructor is a bit of plumbing necessary to make your DomainObject work, since
a DomainObject wraps a DataObject.
Everything else on Binder is there merely to expose the properties of the Binder object type as defined
in the PDL above. Binder’s UI will use the API defined here to fetch data from and to alter Binder
objects.
Note
Binder.java uses string constants that correspond to PDL-defined properties. This way the Java
compiler will catch any typos where the property is used, and a change to the PDL-defined property
name requires changing the Java code in just one place.
It’s a good idea for any WAF application to use logging to monitor important events in the lifecycles
of its objects. In the above example, any time a note is added or removed, we log what happened.
If down the line a bug appears and it’s unclear whether notes are getting added to the binder, the
developer debugging the code can simply enable correct logging and refer to whether addNote is
getting called. For more information about logging in WAF, refer to Section 7.5 Using logging for
debugging.