Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8749219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:39:27+00:00 2026-06-13T12:39:27+00:00

In my project, there are additional (non-wicket) applications, which need to know the URL

  • 0

In my project, there are additional (non-wicket) applications, which need to know the URL representation of some domain objects (e.g. in order to write a link like http://mydomain.com/user/someUserName/ into a notification email).

Now I’d like to create a spring bean in my wicket module, exposing the URLs I need without having a running wicket context, in order to make the other application depend on the wicket module, e.g. offering a method public String getUrlForUser(User u) returning "/user/someUserName/".

I’ve been stalking around the web and through the wicket source for a complete workday now, and did not find a way to retrieve the URL for a given PageClass and PageParameters without a current RequestCycle.

Any ideas how I could achieve this? Actually, all the information I need is somehow stored by my WebApplication, in which I define mount points and page classes.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:39:28+00:00Added an answer on June 13, 2026 at 12:39 pm

    Update: Because the code below caused problems under certain circumstances (in our case, being executed subsequently by a quarz scheduled job), I dived a bit deeper and finally found a more light-weight solution.

    Pros:

    • No need to construct and run an instance of the WebApplication
    • No need to mock a ServletContext
    • Works completely independent of web application container

    Contra (or not, depends on how you look at it):

    • Need to extract the actual mounting from your WebApplication class and encapsulate it in another class, which can then be used by standalone processes. You can no longer use WebApplication’s convenient mountPage() method then, but you can easily build your own convenience implementation, just have a look at the wicket sources.

    (Personally, I have never been happy with all the mount configuration making up 95% of my WebApplication class, so it felt good to finally extract it somewhere else.)

    I cannot post the actual code, but having a look at this piece of code will give you an idea how you should mount your pages and how to get hold of the URL afterwards:

        CompoundRequestMapper rm = new CompoundRequestMapper();
        // mounting the pages
        rm.add(new MountedMapper("mypage",MyPage.class));
        // ... mount other pages ...
    
        // create URL from page class and parameters
        Class<? extends IRequestablePage> pageClass = MyPage.class;
        PageParameters pp = new PageParameters();
        pp.add("param1","value1");
        IRequestHandler handler = new BookmarkablePageRequestHandler(new PageProvider(MyPage.class, pp));
        Url url = rm.mapHandler(handler);
    

    Original solution below:

    After deep-diving into the intestines of the wicket sources, I was able to glue together this piece of code

    IRequestMapper rm = MyWebApplication.get().getRootRequestMapper();
    IRequestHandler handler = new BookmarkablePageRequestHandler(new PageProvider(pageClass, parameters));
    Url url = rm.mapHandler(handler);
    

    It works without a current RequestCycle, but still needs to have MyWebApplication running.

    However, from Wicket’s internal test classes, I have put the following together to construct a dummy instance of MyWebApplication:

    MyWebApplication dummy = new MyWebApplication();
    dummy.setName("test-app");
    dummy.setServletContext(new MockServletContext(dummy, ""));
    ThreadContext.setApplication(dummy);
    dummy.initApplication();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my project there is a listview which contains textview and checkbox..Here is my
In my project there are large no. of FIXME / TODO which are to
In my project there are some 'Prototype' factories that create instances by cloning a
In my project there is a scenario that user will log in -> browse
When creating a standard MVC 3 project there is an EntityFramework.dll and .xml file
I am using My-eclipse and doing a struts project there is no syntax error
I am using Spring with Hibernate in my project.There are many methods written in
I am using MySQL database and JSP for a project. In my project there
Is there a jQuery project out there, that create on of these Password-strength-meters right
Inside the project folder there is a project's name folder, Release and Debug folder.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.