F.O.O
F.O.O

Reputation: 4960

Mounting a parameter on the root url crashes resource location wicket

in my wicket application settings I wish to mount a username parameter on the root like

mountPage (Profile.class, "/${username}") similar to how twitter maps the usernames to its accounts. In wicket this seems to crash the resource location algorithm. In the sense that all css, js files now load with 404.

Is there a work around this?

Upvotes: 0

Views: 121

Answers (2)

F.O.O
F.O.O

Reputation: 4960

Thanks to martin-g. Override the MountMapper with set the url segments to 1 so it doesn't map to other resources.

 public class UsernameMountUrlMapper extends MountedMapper {

    public UsernameMountUrlMapper(String mountPath,
         Class<? extends IRequestablePage> pageClass) {
       super(mountPath, pageClass);
  }

  @Override
  protected boolean urlStartsWithMountedSegments(Url url) {
      return url.getSegments().size() == 1 &&      !url.getPath().equals("favicon.ico") && !url.getPath().equals("oops") && !url.getPath().equals("Index");
    }

 }

Upvotes: 1

martin-g
martin-g

Reputation: 17513

The code should look like: mountPage (Profile.class, "/${username}"). Note the $ that I've added. This means the named path parameter is mandatory.

Please give more details about the problem if this doesn't solve the issue.

Upvotes: 1

Related Questions