+ Link prevLink = new Link("prevLink") {
+ {
+ if (index - MAX_ROWS * MAX_COLUMNS < 0) {
+ setEnabled(false);
+ }
+ }
+
+ @Override
+ public void onClick() {
+ PageParameters pars = new PageParameters();
+ pars.put("path", path);
+ pars.put("index", index - MAX_ROWS * MAX_COLUMNS);
+ setResponsePage(HomePage.class, pars);
+ }
+ };
+ add(prevLink);
+
+ Link nextLink = new Link("nextLink") {
+ {
+ if (index + MAX_ROWS * MAX_COLUMNS >= album.size()) {
+ setEnabled(false);
+ }
+ }
+
+ @Override
+ public void onClick() {
+ PageParameters pars = new PageParameters();
+ pars.put("path", path);
+ pars.put("index", index + MAX_ROWS * MAX_COLUMNS);
+ setResponsePage(HomePage.class, pars);
+ }
+ };
+ add(nextLink);
+
+ Link parentLink = new Link("parentLink") {
+ {
+ if ("/".equals(path)) {
+ setEnabled(false);
+ }
+ }
+
+ @Override
+ public void onClick() {
+ PageParameters pars = new PageParameters();
+ String parentPath = path.substring(0, path.lastIndexOf("/"));
+ if (parentPath.length() == 0) {
+ parentPath = "/";
+ }
+ pars.put("path", parentPath);
+ pars.put("index", 0);
+ setResponsePage(HomePage.class, pars);
+ }
+ };
+ add(parentLink);
+
+ RepeatingView pageLinks = new RepeatingView("pageLinks");
+ add(pageLinks);
+ for (int i = 0; i < album.size() / MAX_ROWS / MAX_COLUMNS; i++) {
+ final int istart = i * MAX_ROWS * MAX_COLUMNS;
+ Link pageLink = new Link("pageLink") {
+ {
+ if (istart == index) {
+ setEnabled(false);
+ }
+ }
+
+ @Override
+ public void onClick() {
+ PageParameters pars = new PageParameters();
+ pars.put("path", path);
+ pars.put("index", istart);
+ setResponsePage(HomePage.class, pars);
+ }
+ };
+ pageLink.add(new Label("label", i + ""));
+ pageLinks.add(pageLink);
+ WebMarkupContainer container = new WebMarkupContainer(pageLinks.newChildId());
+ container.add(pageLink);
+ pageLinks.add(container);
+ }