This was taken from an example I don't remember where from.
Probably Java thoughts ... but I'm not sure.
package com.eurekify.web.components.dropdown;
import java.io.Serializable;
import java.util.List;
import org.apache.wicket.MarkupContainer;
import org.apache.wicket.ajax.IAjaxIndicatorAware;
import
org.apache.wicket.extensions.ajax.markup.html.WicketAjaxIndicatorAppender;
import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.markup.html.form.IChoiceRenderer;
import org.apache.wicket.model.IModel;
public class DropDownChoiceWithAjaxIndicator extends DropDownChoice
implements
IAjaxIndicatorAware {
private static final long serialVersionUID = 1365817942506006686L;
private final WicketAjaxIndicatorAppender indicatorAppender = new
WicketAjaxIndicatorAppender();
public DropDownChoiceWithAjaxIndicator(String id, IModel choices,
IChoiceRenderer renderer, MarkupContainer markupContainer) {
super(id, choices, renderer);
init(markupContainer);
}
public DropDownChoiceWithAjaxIndicator(String id, IModel model, IModel
choices,
IChoiceRenderer renderer, MarkupContainer markupContainer) {
super(id, model, choices, renderer);
init(markupContainer);
}
public DropDownChoiceWithAjaxIndicator(String id, IModel model, IModel
choices,
MarkupContainer markupContainer) {
super(id, model, choices);
init(markupContainer);
}
public DropDownChoiceWithAjaxIndicator(String id, IModel model,
List<Serializable> data,
IChoiceRenderer renderer, MarkupContainer markupContainer) {
super(id, model, data, renderer);
init(markupContainer);
}
public DropDownChoiceWithAjaxIndicator(String id, IModel model,
List<Serializable> choices, MarkupContainer markupContainer) {
super(id, model, choices);
init(markupContainer);
}
public DropDownChoiceWithAjaxIndicator(String id, IModel choices,
MarkupContainer markupContainer) {
super(id, choices);
init(markupContainer);
}
public DropDownChoiceWithAjaxIndicator(String id, List<Serializable>
data,
IChoiceRenderer renderer, MarkupContainer markupContainer) {
super(id, data, renderer);
init(markupContainer);
}
public DropDownChoiceWithAjaxIndicator(String id, List<Serializable>
choices,
MarkupContainer markupContainer) {
super(id, choices);
init(markupContainer);
}
public DropDownChoiceWithAjaxIndicator(String id, MarkupContainer
markupContainer) {
super(id);
init(markupContainer);
}
public String getAjaxIndicatorMarkupId() {
return indicatorAppender.getMarkupId();
}
private void init(MarkupContainer markupContainer) {
add(indicatorAppender);
}
}
On Thu, Apr 17, 2008 at 6:46 PM, Don Hass <[EMAIL PROTECTED]> wrote:
> Could you post the code of:
> com.eurekify.web.components.dropdown.DropDownChoiceWithAjaxIndicator;
>
> Since it is not a standard DDC.
>
> Thanks for sharing!
>
> On Thu, Apr 17, 2008 at 8:59 AM, Eyal Golan <[EMAIL PROTECTED]> wrote:
> > Ok.
> > Here is the code:
> >
> > package com.eurekify.web.components.table;
> >
> > import java.util.ArrayList;
> > import java.util.Collections;
> > import java.util.HashSet;
> > import java.util.List;
> > import java.util.Set;
> >
> > import org.apache.wicket.ajax.AjaxRequestTarget;
> > import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
> > import org.apache.wicket.behavior.HeaderContributor;
> > import org.apache.wicket.behavior.SimpleAttributeModifier;
> > import
> >
> org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractToolbar;
> > import
> > org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable;
> > import org.apache.wicket.markup.html.WebMarkupContainer;
> > import org.apache.wicket.markup.html.basic.Label;
> > import org.apache.wicket.model.AbstractReadOnlyModel;
> > import org.apache.wicket.model.IModel;
> > import org.apache.wicket.model.Model;
> > import org.apache.wicket.model.PropertyModel;
> >
> > import com.eurekify.i18n.LocalizationHelper;
> > import
> com.eurekify.web.components.dropdown.DropDownChoiceWithAjaxIndicator;
> >
> > class NumRecordsToolbar extends AbstractToolbar {
> > private static final long serialVersionUID = -7038331743460229883L;
> >
> > NumRecordsToolbar(DataTable table, int initialRecordsPerPage) {
> > super(table);
> >
> > add(HeaderContributor.forCss("/eurekify/style/EurekifyDataTable.css"));
> > WebMarkupContainer span = new WebMarkupContainer("span");
> > add(span);
> > span.add(new SimpleAttributeModifier("colspan", String
> > .valueOf(getTable().getColumns().length)));
> > span.add(getUsersPerPageSelect(initialRecordsPerPage));
> > Label numOfRecordLabel = new Label("pagingLabel", new
> > Model(LocalizationHelper
> > .getMessage("table.recordsPerPage")));
> > span.add(numOfRecordLabel);
> > getTable().setRowsPerPage(initialRecordsPerPage);
> > }
> >
> > private List<Integer> getValuesForSelect(int initial) {
> > Set<Integer> set = new HashSet<Integer>();
> > set.add(10);
> > set.add(20);
> > set.add(50);
> > set.add(500);
> > set.add(initial);
> > List<Integer> values = new ArrayList<Integer>(set);
> > Collections.sort(values);
> > return values;
> > }
> >
> > private DropDownChoiceWithAjaxIndicator getUsersPerPageSelect(final
> int
> > initial) {
> > final IModel pagingvalues = new AbstractReadOnlyModel() {
> > private static final long serialVersionUID = 1L;
> >
> > @Override
> > public Object getObject() {
> > List<Integer> values = getValuesForSelect(initial);
> > return values;
> > }
> > };
> > final DropDownChoiceWithAjaxIndicator result = new
> > DropDownChoiceWithAjaxIndicator(
> > "pagingSelect", new PropertyModel(getTable(),
> > "rowsPerPage"), pagingvalues,
> > this);
> > result.add(new AjaxFormComponentUpdatingBehavior("onchange") {
> > private static final long serialVersionUID = 1L;
> >
> > @Override
> > protected void onUpdate(AjaxRequestTarget target) {
> > target.addComponent(getTable());
> > }
> > });
> > return result;
> > }
> >
> > @Override
> > public boolean isVisible() {
> > return (getTable().getRowCount() > 10);
> > }
> > }
> >
> >
> > And the HTML:
> > <?xml version="1.0"?>
> > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
> > http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> > <html xmlns="http://www.w3.org/1999/xhtml"
> > xmlns:wicket="http://wicket.sourceforge.net/" xml:lang="en"
> lang="en">
> > <wicket:panel>
> > <tr>
> > <td wicket:id="span" class="select-number-records"><label
> > wicket:id="pagingLabel"> </label> <select
> > wicket:id="pagingSelect">
> > </select></td>
> > </tr>
> > </wicket:panel>
> > </html>
> >
> >
> > On Thu, Apr 17, 2008 at 1:57 PM, Maurice Marrink <[EMAIL PROTECTED]>
> wrote:
> >
> > > Ehm, Attachments are filtered from the list :)
> > >
> > > Maurice
> > >
> > > On Thu, Apr 17, 2008 at 12:23 PM, Eyal Golan <[EMAIL PROTECTED]>
> wrote:
> > > > Hi,
> > > > I have made a toolbar for a DataTable that let's the user select
> how
> > > many
> > > > records will be in a page.
> > > >
> > > > Usage:
> > > > addBottomToolbar(new NumRecordsToolbar(this, rowsPerPage));
> > > >
> > > >
> > > > Enjoy :)
> > > > --
> > > > Eyal Golan
> > > > [EMAIL PROTECTED]
> > > >
> > > > Visit: http://jvdrums.sourceforge.net/
> > > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> > >
> >
> >
> > --
> > Eyal Golan
> > [EMAIL PROTECTED]
> >
> > Visit: http://jvdrums.sourceforge.net/
> >
>
--
Eyal Golan
[EMAIL PROTECTED]
Visit: http://jvdrums.sourceforge.net/