Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: How to redirect to an intermediate page and return

...

Code Block
public class WishlistPage extends WebPage {

       public WishlistPage(PageParameters params) {
               User user = ((MyAppSession)getSession()).getUser(); // MyAppSession extends WebSession and stores the current user
               if (!user.loggedIn()) {
                    redirectToInterceptPage(new LoginPage());
               }
                    ...
       }
       ...
  }

And in LoginPage:

Code Block
public class LoginPage extends WebPage {        public LoginPage(PageParameters params) {
	// Custon login form
	LoginForm form = new LoginForm("form");
	add(form);
       }
...
       public class LoginForm extends Form {
             ...	public LoginForm(String id) {
		super(id);
		// add login components
		add(new TextField("username" ...);
		...
	}
               protected void onSubmit() {
		...
		if (loginOk(username, password)) {
                            	continueToOriginalDestination();
                       	}
               }
       }
}