Peter Parson created WICKET-5004:
------------------------------------

             Summary: Add light-weight possibility to generate URLs from Page 
and PageParameters without having the WebApplication actually running.
                 Key: WICKET-5004
                 URL: https://issues.apache.org/jira/browse/WICKET-5004
             Project: Wicket
          Issue Type: Improvement
          Components: wicket
    Affects Versions: 6.5.0
            Reporter: Peter Parson


In certain scenarios it is useful to be able to generate wicket URLs without 
having the wicket application running, i.e. a mail notification system running 
which needs to include dynamic URLs in the mails, or an XML sitemap generator 
running on a different server.

With Wicket 1.3.x, this was an easy task: we just needed to (statically) 
provide the UrlRequestCodingStrategy, the PageClass and PageParameters and any 
other module depending on our wicket module could obtain the URLs.

With Wicket 6.x it's not so easy, it seems to be impossible without having the 
application actually running. I have found the solution I have described here: 
http://stackoverflow.com/questions/13015743/how-to-obtain-wicket-url-from-pageclass-and-pageparameters-without-running-wicke
But this seems to be a little hacky, and causes problems if executed multiple 
times (since the WebApplication is somewhere registered within the context, but 
cannot be destroyed)



A code example from our old (1.3.x) solution, to give you an idea of what we 
did.

We had a spring bean in our Wicket module which offered methods like this:

public String getUrlFor(MyDomainObject o) {
        Class pClass = MyDomainObjectTargetPage.class;
        PageParameters pp = MyDomainObjectTargetPage.pageParametersFor(o);
        IRequestTargetUrlCodingStrategy urlCodingStragy = 
MyDomainObjectTargetPage.URL_CODING_STRATEGY;
        BookmarkablePageRequestTarget target = new 
BookmarkablePageRequestTarget(pClass, pp);
        return "/" + urlCodingStragy.encode(target).toString()
}


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to