Recently we have been doing quite a lot of hardcore customizations on Atlassian's Confluence.
Often we find ourselves in a situation where we would like to have more control over the application's default behaviour. Confluence allows us to override some of the velocity files, or extend the default actions into our own custom actions, but some times these don't seem to be enough.
Suppose we want to override an action added by a third-party plugin or modify the flow of an existing action only for a given result.
We finally found out how to have full control over Confluence's configurations through XWork's configuration providers.
It is quite simple, but should probably be used with care.
Let's say we want to change the result of the default Confluence's edit page action.
All we have to do is, using the classes under com.opensymphony.xwork.config:
String packageName = "pages"; String actionName = "editpage"; String resultName = "input"; String newResultLocation = "/com/aqris/actions/document/newEditPage.vm"; Configuration configuration = ConfigurationManager.getConfiguration(); PackageConfig packageConfig = configuration.getPackageConfig(packageName); ActionConfig actionConfig = (ActionConfig) packageConfig.getActionConfigs().get(actionName); ResultConfig resultConfig = (ResultConfig) actionConfig.getResults().get(resultName); resultConfig.addParam("location", newResultLocation);
Now just modify the package, action and result names for those you want to modify and that's it.
In many cases creating a custom action that inherits from EditPageAction can be the most appropriate solution, but in some cases we might need some more advanced control over the system.
But never forget: with great powers come great responsibilities!