Click
Click Examples

Source Viewer : WEB-INF/classes/org/apache/click/examples/page/introduction/LinkListPage.java

package org.apache.click.examples.page.introduction;

import java.util.ArrayList;
import java.util.List;
import org.apache.click.ActionListener;
import org.apache.click.Control;
import org.apache.click.control.ActionLink;
import org.apache.click.examples.page.BorderPage;

/**
 * Provides an example on adding a list of ActionLinks to a page.
 */
public class LinkListPage extends BorderPage {

    private static final long serialVersionUID = 1L;

    /* List of ActionLinks. */
    private List links = new ArrayList();

    /** An output message. */
    private String msg;

    public LinkListPage() {
        for (int i = 0; i < 3; i++) {

            ActionLink link = new ActionLink("link" + i);
            link.setActionListener(new ActionListener() {

                public boolean onAction(Control source) {
                    msg = "ControlListenerListPage#" + source.getName()
                        + " object method <tt>onLinkClick()</tt> invoked.";

                    addModel("msg", msg);
                    return true;
                }
            });

            addControl(link);
            links.add(link);
        }

        addModel("links", links);
    }
}