Category Image Displaying Subclass Attributes in WOBuilder


Let's say we have an abstract class and a few subclasses and the subclasses each have additional attributes. In WOBuilder, if we add the abstract class as a key, usually only its attributes show up. Adding a TypeInfo comment in the source will display the attributes of the subclass so that you can drag to "wire them up"....

Here is an example of a method that returns an abstract reference to a transaction in a user's account. Note that we have three TypeInfo comments each referring to a subclass of the abstract transaction type.

/** @TypeInfo CTAccountRegularTransaction
@TypeInfo CTAccountOnlineTransaction
@TypeInfo CTAccountPeriodEndTransaction */
public CTAccountAbstractTransaction transaction()
{
if ( _transaction == null ) {
_transaction = (CTAccountAbstractTransaction)valueForBinding( "transaction" );
}

return _transaction;
}

WOBuilder displays the attributes of the subclass referenced by the first @TypeInfo statement. Dragging attributes to bind them to WOComponents in WOBuilder is faster than typing and probably less error prone. Remember just because WOBuilder does not display an attribute, it does not mean that key-value coding at runtime will not be able to retrieve an actual value.

Anyway as you design your page and tailor your layout using elements such as ERXInstanceOfConditional you can cut/paste the subclass @TypeInfo statement of the subclass that you are currently "wiring up" to the top of the list so that WOBuilder displays its attributes.

Posted: Tuesday - June 07, 2005 at 04:25 PM        


Published by