Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

This page describes the use of the Link component. It is not meant to replace the available Javadoc. Common usage questions (FAQ) of the component will be addressed here, along with background/design information, and examples where applicable.

To pass your own objects from one page to another as part of link, just use setResponsePage as below, i.e. passing in a instance of the new page created with your custom constructor.

(The example also shows how the 'Edit' page can return to the instance of the 'List' page once editing is complete.)

Code Block
class ListUsersPage extends Webpage {
    .....
    add(new Link("edit") {
        onclick() {
           setResponsePage(new EditUserPage( ListUsersPage.this, (User)getModelObject()));
        }
}

class EditUserPage extends WebPage {
    public EditUserPage(final WebPage backPage, User user) {
            Form form;
            add(form=new Form("form", ));
            form.add(new Button("save") {
                    onsubmit() {
                         //save user
                         setResponsePage(backPage); <=== navigates to the list users page in its previous state
                 });}}

[From a posting of Igor's to the wicket-user list - Gwyn 08:59, 21 Jul 2006 (BST)]