sbrattla
sbrattla

Reputation: 5386

How do I avoid resource path conflicts in Wicket?

I can't get resource paths to work properly in Wicket. What I do is that I have two resources.

The way I mount the two resources to these paths are as below.

   mountResource("/profiles", new ResourceReference("profilesResource") {
        ProfilesResource resource = new ProfilesResource();

        @Override
        public IResource getResource() {
            return resource;
        }

    });

    mountResource("/profiles/{username}/history", new ResourceReference("profilesHistoryResource") {
        ProfilesHistoryResource resource = new ProfilesHistoryResource();

        @Override
        public IResource getResource() {
            return resource;
        }

    });

However, this does not work. Once I introduce the /profiles/{username}/history resource things just stop working and I get the following error when I attempt to load /profiles/testuser/history:

No suitable method found. URL 'profiles/testuser/rentalaccesses' and HTTP method GET

What am I doing wrong here? Why does these mappings not work?

ProfilesResource

public class ProfilesResource extends GenericRestResource {

    @MethodMapping(value = "/{username}", httpMethod = HttpMethod.GET)
    public String get(String username) {
        return "success";
    }

ProfilesHistoryResource

public class ProfilesHistoryResource extends GenericRestResource {

    @MethodMapping(value = "/", httpMethod = HttpMethod.GET)
    public String get(String username) {
        return "success";
    }

}

Upvotes: 0

Views: 133

Answers (1)

martin-g
martin-g

Reputation: 17503

Apache Wicket (core) doesn't support {placeholder}. It supports ${mandatory} and #{optional}. You definitely cannot use {..} with WebApplication#mountResource()`.

WicketStuff RestAnnotations supports @MethodMapping and co.

Upvotes: 1

Related Questions