Previous | Next | WireHose Developers Guide |
Since WireHose is an object-oriented system, with a strong emphasis on code reuse, there is a clean separation between business logic and presentation components. For maximum flexibility, WireHose allows you to use any component to render or edit an object on a page. Special components called "switchers" keep WireHose updated as to which object is currently being rendered or edited.
public RSSItem item() { return (RSSItem)object(); }
Note: This method isn't strictly required; it's a convenience so that WebObjects Builder will display the bindings available for RSSItem objects. You can bind values such as the item's name to either object.name or item.name. |
Note: Since "title" is an optional attribute in an RSS item, you may want to use WOConditional components to render the link differently depending on whether or not the item has a name. |
Since it's traditional in an aggregator to indicate where an item originated, you can add a link to the item's feed. This link will use the WireHose "Display" direct action, which acts as a cover for the WHShowObjectPage component. The Display direct action takes one parameter, "resource", set to the global ID of the object to be displayed. WHEnterpriseObject provides utility methods to encode and decode globalIDs as compact strings suitable for this purpose.
public String feedGlobalID() { return WHEnterpriseObject.encodedGlobalIDForObject(feed()); }
The final step is to modify the layout dictionary to tell the WHSwitchRenderer components to use ShowRSSItem instead of WHShowResource.
renderers = { WHChannel = WHShowChannel; WHComponentChannel = WHShowComponentChannel; WHFetcher = WHShowFetcher; WHResource = WHShowResource; };
renderers = { WHChannel = WHShowChannel; WHComponentChannel = WHShowComponentChannel; WHFetcher = WHShowFetcher; WHResource = WHShowResource; RSSItem = ShowRSSItem; };
http://127.0.0.1:2020/cgi-bin/WebObjects/HelloWorld.woa/wa/Drill
You'll see your new component is being used to display items.
Note: Since there is a to-many relationship between RSSFeed and RSSItem, you could build a ShowRSSFeed component, and include an option to show the individual items for a feed. To do this, you would embed a
WHSwitchRenderer component inside a WORepetition which
iterates over the feed's items, and set the switcher's
|
At this point the business logic for Hello World is complete. RSS feeds and items are modeled and being imported into the database. The next step will be to customize Hello World's user interface so users can search items, login and create personalized topics for their page.
Copyright ©2000-2003 Gary Teter. All rights reserved. WireHose is a trademark of Gary Teter.