Previous | Next
WireHose Developers Guide

Add this to my page

WHTagDrillerPage determines whether or not to show an "add this to my page" button by calling WHApplicationHelper's userCanEditObject method, with the user as the object in question. By default, the guest user isn't permitted to edit anything, so you'll override that behavior by implementing a method from the WHApplicationHelper.Delegate interface.

  1. Uncomment this line in Application.java's constructor:
    WHApplicationHelper.setDelegate(this);
  2. Add this method:
    public boolean userCanEditObject(WHUser user, Object object, WOContext context) {
        if (user.isGuest() && user.equals(object) && 
            "WHTagDrillerPage".equals(context.page().valueForKey("pageName"))) {
            return true;
        } else {
            return super.userCanEditObject(user, object, context);
        }
    }

    When the tag driller page checks to see if the user can edit itself, WHApplicationHelper will call this method, and it will return true, so the button will be displayed.

  3. Build and launch the application, then open this URL in your browser:
    http://127.0.0.1:2020/
  4. When you browse to a tag which has matching resources, the "Add this to my page" will appear.

    In the next section, you'll build a custom subclass of WHTagDrillerPage so Hello World can create a new user when the button is clicked.


Previous | Next