سؤال

What I'm trying to do is a simple page that gets one parameter which is an id of an object.

    @MountPath("share/${share_id}")
    public class IndexPage extends WebPage
    {
            public IndexPage(PageParameters parameters)
            {
                    String id = parameters.get("share_id").toString();
                    // etc...
            }
    }

This page has to be secured from unauthorised visits. I've added @AuthorizeInstantiation("user") annotation and managed standard Wicket security support including getSignInPageClass() in MainApplication that extends AuthenticatedWebApplication.

The problem is when I need to get back to my IndexPage after authorization with original parameters. I got some solution but I need it to be more elegant and more common (universal).

  1. Override restartResponseAtSignInPage() method in Application class
  2. Retrieve parameters from RequestCycle:

    final Request request = RequestCycle.get().getRequest();
    PageParametersEncoder encoder = new PageParametersEncoder();
    PageParameters parameters = encoder.decodePageParameters(request.getUrl());
    
  3. Pass them by throwing new RestartResponseAtInterceptPageException(getSignInPageClass(), newParameters);

I know it's not a nice solution because I need to be sure what is exact index of parameter in my url (encoder returns only indexedParameters, not namedParameters - or I am doing sth wrong?).

Maybe there is somebody that has met that problem before?

هل كانت مفيدة؟

المحلول

In your Siginpage, after you have verified the login, make a call to continueToOriginalDestination();

This should do the trick.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top