Jesse Barnum
Jesse Barnum

Reputation: 6816

Get a URL of the current page in Wicket for an OAuth redirect

I need to forward my user to an OAuth provider for login, and then pass a redirect URL to the OAuth provider. I'd like for the user to return to the same stateful page that they were currently on. In Apache Wicket (version 7), how can I generate a full URL that will take them back to the current page?

I'm looking for an external URL that will do the equivalent of:

add( new Link<Object>( "samePage") {
        @Override
        public void onClick() {
            setResponsePage( getPage() );
        }
    } );
}

Upvotes: 0

Views: 181

Answers (2)

Jesse Barnum
Jesse Barnum

Reputation: 6816

I think I figured it out - this approach generates a new render count, and works even from panels / components within the parent page:

String redirect = getRequestCycle().getUrlRenderer().renderFullUrl( Url.parse( getPage().urlFor( IRedirectListener.INTERFACE, new PageParameters() ) ) )

Upvotes: 1

Andrea Del Bene
Andrea Del Bene

Reputation: 2511

I use the following code to obtain a full URL of the current page, but it's for 9.x, can't test 7.x:

Url currentUrl = ((WebRequest)RequestCycle.get().getRequest()).getUrl();
String fullUrl = RequestCycle.get().getUrlRenderer().renderFullUrl(currentUrl);

Upvotes: 1

Related Questions