| Previous | Next | WireHose Developers Guide |
The "add this to my page" button is bound to WHTagDrillerPage's
addTag method. In this step, you'll subclass
WHTagDrillerPage and override the addTag method so that it returns a
signup page if the current user is a guest.
Because the layout dictionary may specify that pages may be
substituted in a particular layout, here we'll use the session
helper's nameForPage method to determine the actual page
class to return from addTag().
public class TagDrillerPage extends WHTagDrillerPage {
public TagDrillerPage(WOContext context) {
super(context);
}
public boolean shouldUseAlternateTemplate() {
return true;
}
public WOActionResults addTag() {
if (helper().user().isGuest()) {
SignupPage nextPage =
(SignupPage)pageWithName(helper().nameForPage("SignupPage"));
nextPage.setTag(tag());
return nextPage;
} else {
return super.addTag();
}
}
}WHTagDrillerPage = {
...
pageName = WHTagDrillerPage;
...
Change it so it reads:
WHTagDrillerPage = {
...
pageName = TagDrillerPage;
...
WireHose will now use TagDrillerPage instead of WHTagDrillerPage.
|
How this works: In this example, we're subclassing WHTagDrillerPage to modify behavior, but not duplicating any of its HTML or .wod definitions. The page will still look just like a WHTagDrillerPage, though. The key is the
You can override
|
Copyright ©2000-2003 Gary Teter. All rights reserved. WireHose is a trademark of Gary Teter.