org.wicketstuff.datatable_autocomplete.table.column.DTARadioColumn Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of wicketstuff-datatable-autocomplete Show documentation
Show all versions of wicketstuff-datatable-autocomplete Show documentation
The Datatable autocomplete project provides a Trie datastructure that allows AJAX searches on large datasets fast.
It is not memory efficient but it is fast especially to know how many results a given prefix matches.
Provides a Datatable component when tied to a textfield will show the matched objects in a table format.
/*
*
* ==============================================================================
* Licensed 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.wicketstuff.datatable_autocomplete.table.column;
import java.util.LinkedList;
import java.util.List;
import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;
import org.apache.wicket.markup.html.form.Radio;
import org.apache.wicket.markup.html.form.RadioGroup;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.wicketstuff.datatable_autocomplete.radio.DTARadio;
/**
* @author mocleiri
*
* A radio for use where the table this column is added to is wrapped by a
* {@link RadioGroup}
*
*/
public class DTARadioColumn extends AbstractColumn
{
/**
*
*/
private static final long serialVersionUID = -24109845922068732L;
private List> radioList = new LinkedList>();
/**
* @param displayModel
*/
public DTARadioColumn(IModel displayModel)
{
super(displayModel);
// TODO Auto-generated constructor stub
}
/**
* @param columnName
*/
public DTARadioColumn(String columnName)
{
this(new Model(columnName));
}
/*
* (non-Javadoc)
*
* @see
* org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator#populateItem(org
* .apache.wicket.markup.repeater.Item, java.lang.String, org.apache.wicket.model.IModel)
*/
public void populateItem(Item> cellItem, String componentId,
IModel rowModel)
{
DTARadio rd;
cellItem.add(rd = new DTARadio(componentId, rowModel));
rd.setOutputMarkupId(true);
// should have a worst case size of visible page size.
radioList.add(rd);
}
/*
* (non-Javadoc)
*
* @see org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn#detach()
*/
@Override
public void detach()
{
super.detach();
// this.radioList.clear();
}
/**
* Get the markupid for the radio representing a specific row. Used to allow row onclick actions
* to trigger a radio selection DOM action.
*
* @param index
* @return the markup id for the radio for the row index given.
*/
public final String getRadioMarkupID(int index)
{
Radio radio = radioList.get(index);
if (radio == null)
return null;
else
return radio.getMarkupId();
}
}