How to add condition to webwork


I would like to create a top-menu button like the default ‘create’ that redirects to custom page.

my code id:

<web-item key="topbutton" section="" weight="50">
        <label key="My button"/>
        <condition class="com.plugin.TopButtonCondition"/>

    <webwork1 key="mywebwork" name="My WebWork" class="java.lang.Object">
            <action name="com.WebWorkAction" alias"WebWorkActionPage">
                <view name="success">/templates/myWebWork.vm</view>

The permission is added in plugin configuration so only some users should have access to the ‘top-menu’ button and ‘custom-page’. I would like to check that in TopButtonCondition class.

It works correctly for ‘top-menu’ button and I’m able to make it invisible for unauthorized users.

The problem is that if someone knows url ‘/secure/WebWorkActionPage.jspa’ - can access to this page.

How is it possible to add condition to webwork? I tried to do in the same way as in the ‘web-section’ (in tags 'webwork1 ', ‘actions’ and ‘action’) but it does not work.

Does anyone know the solution?

I would also include the validation in the doValidation method of the action in order to redirect to an error page.

@jportillo I’m not sure what do you mean. The class ‘WebWorkAction’ extends ‘JiraWebAcionSupports’ but there is no ‘doValidation()’ method to override.
Could you explain me the solution please?

You can use it anyway becasue is a method from ActionSupport Class.

Just include a method like this:

public void doValidation() {


public class MyProjectAction extends JiraWebActionSupport{ 

    private final PermissionManager permissionManager;

    private final ProjectManager projectManager;

    private Long projectId;

    private Project project;

    public MyProjectAction(PermissionManager permissionManager, ProjectManager projectManager){
        this.permissionManager = permissionManager;
        this.projectManager = projectManager;

    public String doDefault(){


        // getters and setters need to be defined for current project and for permissionManager
        if (!this.permissionManager.hasPermission(Permissions.PROJECT_ADMIN, getProject(), getLoggedInUser())) {
            this.setReturnUrl("/projects/" + getProject().getKey());
            return this.getRedirect("/projects/" + getProject().getKey());
        // Your action here
       return "myVelocity";

    public Project getProject() {
        return project;

    public void setProject(Project project) {
        this.project = project;
<webwork1 key="my_webwork" roles-required="use">