urlwicketwicket-1.5

delete version number in url


How can I delete or hide the version number in the URL introduced in Wicket 1.5?

Mounting a page doesn't help.

http://localhost/MyPage/SubPage?0

Solution

  • In Application.init():

    mount(new MountedMapperWithoutPageComponentInfo("/subpage", MyPage.class));
    

    with the following Mapper class:

    public class MountedMapperWithoutPageComponentInfo extends MountedMapper {
    
      public MountedMapperWithoutPageComponentInfo(String mountPath, Class<? extends IRequestablePage> pageClass) {
        super(mountPath, pageClass, new PageParametersEncoder());
      }
    
      @Override
      protected void encodePageComponentInfo(Url url, PageComponentInfo info) {
        // do nothing so that component info does not get rendered in url
      }
    
      @Override 
      public Url mapHandler(IRequestHandler requestHandler) 
      { 
          if (requestHandler instanceof ListenerInterfaceRequestHandler ||
                    requestHandler instanceof BookmarkableListenerInterfaceRequestHandler) { 
              return null; 
          } else { 
               return super.mapHandler(requestHandler); 
          } 
      } 
    }