This Confluence has been LDAP enabled, if you are an ASF Committer, please use your LDAP Credentials to login. Any problems file an INFRA jira ticket please.

Child pages
  • Using intercept pages
Skip to end of metadata
Go to start of metadata

  • remembering last visited pages and redirection

Not sure if this is the only (or best!) way but... Suppose you want to redirect your response to an intermediate page (like a login page) and then return to what the user was doing or seeing. There are two methods in Component just for that:

redirectToInterceptPage(Page page)

and 

continueToOriginalDestination()

In your current Page you may use:

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:

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)) {
                	// continue to original requested destination if exists, otherwise go to a default home page
                	if (!continueToOriginalDestination()) {
                		setResponsePage(getApplication().getHomePage());
                	}
            	}
        }
    }
} 
  • No labels