Package org.apache.wicket.extensions.markup.html.repeater.data.table

Source Code of org.apache.wicket.extensions.markup.html.repeater.data.table.NavigationToolbar

/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements.  See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License.  You may obtain a copy of the License at
*
*      http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.wicket.extensions.markup.html.repeater.data.table;

import org.apache.wicket.AttributeModifier;
import org.apache.wicket.markup.html.WebComponent;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.navigation.paging.PagingNavigator;
import org.apache.wicket.model.Model;

/**
* Toolbar that displays links used to navigate the pages of the datatable as well as a message
* about which rows are being displayed and their total number in the data table.
*
* @author Igor Vaynberg (ivaynberg)
*/
public class NavigationToolbar extends AbstractToolbar
{
  private static final long serialVersionUID = 1L;

  private final DataTable<?> table;

  /**
   * Constructor
   *
   * @param table
   *            data table this toolbar will be attached to
   */
  public NavigationToolbar(final String id, final DataTable<?> table)
  {
    super(id, table);
    this.table = table;

    WebMarkupContainer span = new WebMarkupContainer("span");
    add(span);
    span.add(new AttributeModifier("colspan", true, new Model<String>(
      String.valueOf(table.getColumns().length))));

    span.add(newPagingNavigator("navigator", table));
    span.add(newNavigatorLabel("navigatorLabel", table));
  }

  /**
   * Factory method used to create the paging navigator that will be used by the datatable
   *
   * @param navigatorId
   *            component id the navigator should be created with
   * @param table
   *            dataview used by datatable
   * @return paging navigator that will be used to navigate the data table
   */
  protected PagingNavigator newPagingNavigator(String navigatorId, final DataTable<?> table)
  {
    return new PagingNavigator(navigatorId, table);
  }

  /**
   * Factory method used to create the navigator label that will be used by the datatable
   *
   * @param navigatorId
   *            component id navigator label should be created with
   * @param table
   *            dataview used by datatable
   * @return navigator label that will be used to navigate the data table
   *
   */
  protected WebComponent newNavigatorLabel(String navigatorId, final DataTable<?> table)
  {
    return new NavigatorLabel(navigatorId, table);
  }

  /**
   * @see org.apache.wicket.Component#callOnBeforeRenderIfNotVisible()
   */
  @Override
  protected boolean callOnBeforeRenderIfNotVisible()
  {
    return true;
  }

  /** {@inheritDoc} */
  @Override
  protected void onBeforeRender()
  {
    setVisible(table.getPageCount() > 1);
    super.onBeforeRender();
  }
}
TOP

Related Classes of org.apache.wicket.extensions.markup.html.repeater.data.table.NavigationToolbar

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.