Changeset 4554


Ignore:
Timestamp:
02/25/14 11:10:04 (10 years ago)
Author:
twagoo
Message:

added selector for number of results per page

Location:
vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/components
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/components/SearchResultsPanel.html

    r4553 r4554  
    115115                <wicket:container wicket:id="pagingBottom">[PAGING]</wicket:container>
    116116
    117                 <form id="resultpagesizeform">
     117                <form wicket:id="resultPageSizeForm" id="resultpagesizeform">
    118118                    <label for="resultpagesize">Results per page:</label>
    119                     <select id="resultpagesize">
     119                    <select wicket:id="resultPageSize" id="resultpagesize">
    120120                        <option>5</option>
    121121                        <option>10</option>
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/components/SearchResultsPanel.java

    r4553 r4554  
    2323import eu.clarin.cmdi.vlo.wicket.model.SolrFieldModel;
    2424import eu.clarin.cmdi.vlo.wicket.provider.SolrDocumentProvider;
     25import java.util.Arrays;
     26import java.util.List;
    2527import org.apache.solr.common.SolrDocument;
     28import org.apache.wicket.ajax.AjaxRequestTarget;
     29import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
    2630import org.apache.wicket.ajax.markup.html.navigation.paging.AjaxPagingNavigator;
    2731import org.apache.wicket.markup.html.basic.Label;
     32import org.apache.wicket.markup.html.form.DropDownChoice;
     33import org.apache.wicket.markup.html.form.Form;
    2834import org.apache.wicket.markup.html.navigation.paging.IPageableItems;
    2935import org.apache.wicket.markup.html.panel.Panel;
     
    3339import org.apache.wicket.model.AbstractReadOnlyModel;
    3440import org.apache.wicket.model.IModel;
     41import org.apache.wicket.model.PropertyModel;
    3542import org.apache.wicket.spring.injection.annot.SpringBean;
    3643
     
    4148 */
    4249public class SearchResultsPanel extends Panel {
     50
     51    public static final List<Long> ITEMS_PER_PAGE_OPTIONS = Arrays.asList(5L, 10L, 25L, 50L, 100L);
    4352
    4453    @SpringBean
     
    6473        add(createResultPageIndicator("resultPageIndicator", resultsView));
    6574
     75        // form to select number of results per page
     76        add(createResultPageSizeForm("resultPageSizeForm", resultsView));
     77
    6678        //For Ajax updating of search results
    6779        setOutputMarkupId(true);
     
    8496    private Label createResultCount(String id) {
    8597        final IModel<String> resultCountModel = new AbstractReadOnlyModel<String>() {
    86            
     98
    8799            @Override
    88100            public String getObject() {
     
    106118    }
    107119
     120    private Form createResultPageSizeForm(String id, final IPageableItems resultsView) {
     121        final Form resultPageSizeForm = new Form(id);
     122
     123        final DropDownChoice<Long> pageSizeDropDown
     124                = new DropDownChoice<Long>("resultPageSize",
     125                        // bind to items per page property of pageable
     126                        new PropertyModel<Long>(resultsView, "itemsPerPage"),
     127                        ITEMS_PER_PAGE_OPTIONS);
     128        pageSizeDropDown.add(new AjaxFormComponentUpdatingBehavior("onchange") {
     129
     130            @Override
     131            protected void onUpdate(AjaxRequestTarget target) {
     132                target.add(SearchResultsPanel.this);
     133            }
     134        });
     135        resultPageSizeForm.add(pageSizeDropDown);
     136
     137        return resultPageSizeForm;
     138    }
     139
    108140    public static class SolrFieldLabel extends Label {
    109141
Note: See TracChangeset for help on using the changeset viewer.