Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Pretty slick eh? Note, the reason why there is no default required weblog permission is mostly to alleviate any confusion about required permissions for actions. Basically, we want the action classes to define the requiredWeblogPermissions() method as shown above so that anyone working on the action can see directly in that class what the enforced permissions are.

So, now that we have some nice action freebies already set for us and we've defined the security for our action, lets look at the myPrepare() method to see how we can use that to easily do common preparation code that our action uses.

myPrepare() method

The myPrepare() method is basically a way for actions to do any setup work that applies to their action before the actual action method is called. This is particularly great for loading things from the database that you know your action methods will need. A good example of this from the ThemeEdit action is how the myPrepare() method loads the list of enabled themes for the action to use.

No Format

public void myPrepare() {
    ThemeManager themeMgr = RollerFactory.getRoller().getThemeManager();
    setThemes(themeMgr.getEnabledThemesList());
}

That's it. Now I know that my action has already looked up the list of themes that are used by all the action methods defined in my action and the code is in a nice and reusable place. So if you have any work that you want to do just before you action method executes, then implement the myPrepare() method.

Tabbed Menu controls

Exception and Error Handling

Migration Walkthrough

Migrating Actions

...