Index: /vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/components/FieldValueOrderSelector.java
===================================================================
--- /vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/components/FieldValueOrderSelector.java	(revision 4665)
+++ /vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/components/FieldValueOrderSelector.java	(revision 4665)
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2014 CLARIN
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package eu.clarin.cmdi.vlo.wicket.components;
+
+import com.google.common.collect.ImmutableList;
+import eu.clarin.cmdi.vlo.pojo.FieldValuesOrder;
+import eu.clarin.cmdi.vlo.wicket.panels.AllFacetValuesPanel;
+import java.util.List;
+import java.util.Locale;
+import org.apache.wicket.extensions.markup.html.repeater.util.SortParam;
+import org.apache.wicket.markup.html.form.DropDownChoice;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.util.convert.ConversionException;
+import org.apache.wicket.util.convert.IConverter;
+
+/**
+ * A drop down choice component that offers a selection of order modes for facet
+ * field values.
+ *
+ * Designed for usage in {@link AllFacetValuesPanel}
+ *
+ * @author twagoo
+ */
+public class FieldValueOrderSelector extends DropDownChoice<SortParam<FieldValuesOrder>> {
+
+    public final static SortParam<FieldValuesOrder> COUNT_SORT = new SortParam<FieldValuesOrder>(FieldValuesOrder.COUNT, false);
+    public final static SortParam<FieldValuesOrder> NAME_SORT = new SortParam<FieldValuesOrder>(FieldValuesOrder.NAME, true);
+    public final static List<SortParam<FieldValuesOrder>> SORT_CHOICES = ImmutableList.of(COUNT_SORT, NAME_SORT);
+    public static final String COUNT_KEY = "fields.order.count";
+    public static final String NAME_KEY = "fields.order.name";
+
+    public FieldValueOrderSelector(String id, IModel<SortParam<FieldValuesOrder>> model) {
+        super(id, model, SORT_CHOICES);
+    }
+
+    @Override
+    public <C> IConverter<C> getConverter(Class<C> type) {
+        if (type == SortParam.class) {
+            // This should always be the case
+            return (IConverter<C>) new FieldValueSortParamConverter();
+        } else {
+            return super.getConverter(type);
+        }
+    }
+
+    /**
+     * Converts between sort parameter objects and string representations
+     * thereof (string values coming from a properties resource bundle)
+     */
+    private class FieldValueSortParamConverter implements IConverter<SortParam<FieldValuesOrder>> {
+
+        @Override
+        public SortParam<FieldValuesOrder> convertToObject(String value, Locale locale) throws ConversionException {
+            if (value.equals(getString(NAME_KEY))) {
+                return NAME_SORT;
+            } else if (value.equals(getString(COUNT_KEY))) {
+                return COUNT_SORT;
+            } else {
+                throw new ConversionException("Unknown value " + value);
+            }
+        }
+
+        @Override
+        public String convertToString(SortParam<FieldValuesOrder> value, Locale locale) {
+            switch (value.getProperty()) {
+                case NAME:
+                    return getString(NAME_KEY);
+                case COUNT:
+                    return getString(COUNT_KEY);
+                default:
+                    return "???";
+            }
+        }
+    }
+
+}
Index: /vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/components/FieldValueOrderSelector.properties
===================================================================
--- /vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/components/FieldValueOrderSelector.properties	(revision 4665)
+++ /vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/components/FieldValueOrderSelector.properties	(revision 4665)
@@ -0,0 +1,17 @@
+# Copyright (C) 2014 CLARIN
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+fields.order.name=Name
+fields.order.count=Result count
Index: /vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/AllFacetValuesPanel.html
===================================================================
--- /vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/AllFacetValuesPanel.html	(revision 4664)
+++ /vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/AllFacetValuesPanel.html	(revision 4665)
@@ -25,10 +25,14 @@
         <wicket:panel>
             <p>All values in this facet</p>
-            <p>Sort by <select><option>name</option><option>count</option></select></p>
-            <div>Search: <input type="text" /></div>
-            <div class="sortedFacet">
-<!--                <div>
-                    <div class="anchorpanel"><a href=""></a><span>A</span></div>
-                </div>-->
+            <form wicket:id="options">
+                <p>Sort by <select wicket:id="sort"><option>name</option><option>count</option></select></p>
+                <div>Search: <input type="text" /></div>
+            </form>
+            <div wicket:id="facetValuesContainer" class="sortedFacet">
+                <!--                
+                    <div>
+                        <div class="anchorpanel"><a href=""></a><span>A</span></div>
+                    </div>
+                -->
                 <div wicket:id="facetValue">
                     <div class="facetLinkPanel"><a wicket:id="facetSelect" href=""><span wicket:id="name">A Corpus</span></a> (<span wicket:id="count">1</span>)</div>
Index: /vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/AllFacetValuesPanel.java
===================================================================
--- /vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/AllFacetValuesPanel.java	(revision 4664)
+++ /vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/AllFacetValuesPanel.java	(revision 4665)
@@ -17,4 +17,6 @@
 package eu.clarin.cmdi.vlo.wicket.panels;
 
+import eu.clarin.cmdi.vlo.wicket.components.FieldValueOrderSelector;
+import eu.clarin.cmdi.vlo.pojo.FieldValuesOrder;
 import eu.clarin.cmdi.vlo.wicket.provider.FacetFieldValuesProvider;
 import java.util.Collection;
@@ -22,6 +24,11 @@
 import org.apache.solr.client.solrj.response.FacetField;
 import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
 import org.apache.wicket.ajax.markup.html.AjaxFallbackLink;
+import org.apache.wicket.extensions.markup.html.repeater.util.SortParam;
+import org.apache.wicket.markup.html.WebMarkupContainer;
 import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.form.DropDownChoice;
+import org.apache.wicket.markup.html.form.Form;
 import org.apache.wicket.markup.html.link.Link;
 import org.apache.wicket.markup.html.panel.GenericPanel;
@@ -30,6 +37,9 @@
 import org.apache.wicket.model.CompoundPropertyModel;
 import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.PropertyModel;
 
 /**
+ * A panel that shows all available values for a selected facet. Supports two
+ * ordering modes (by name or result count) and dynamic filtering.
  *
  * @author twagoo
@@ -37,10 +47,25 @@
 public abstract class AllFacetValuesPanel extends GenericPanel<FacetField> {
 
+    private final FacetFieldValuesProvider valuesProvider;
+    private final WebMarkupContainer valuesContainer;
+
     public AllFacetValuesPanel(String id, IModel<FacetField> model) {
         super(id, model);
+        valuesProvider = new FacetFieldValuesProvider(model);
 
-        // provider that extracts values and counts from FacetField
-        final FacetFieldValuesProvider valuesProvider = new FacetFieldValuesProvider(model);
-        add(new DataView<FacetField.Count>("facetValue", valuesProvider) {
+        valuesContainer = new WebMarkupContainer("facetValuesContainer");
+        valuesContainer.setOutputMarkupId(true);
+        add(valuesContainer);
+
+        final DataView<FacetField.Count> valuesView = createValuesView("facetValue");
+        valuesContainer.add(valuesView);
+
+        final Form optionsForm = createOptionsForm("options");
+        optionsForm.setOutputMarkupId(true);
+        add(optionsForm);
+    }
+
+    private DataView<FacetField.Count> createValuesView(String id) {
+        return new DataView<FacetField.Count>(id, valuesProvider) {
 
             @Override
@@ -69,5 +94,21 @@
                 item.add(new Label("count"));
             }
+        };
+    }
+
+    private Form createOptionsForm(String id) {
+        final Form options = new Form(id);
+        final DropDownChoice<SortParam<FieldValuesOrder>> sortSelect
+                = new FieldValueOrderSelector("sort", new PropertyModel<SortParam<FieldValuesOrder>>(valuesProvider, "sort"));
+        sortSelect.add(new AjaxFormComponentUpdatingBehavior("onchange") {
+
+            @Override
+            protected void onUpdate(AjaxRequestTarget target) {
+                target.add(options);
+                target.add(valuesContainer);
+            }
         });
+        options.add(sortSelect);
+        return options;
     }
 
@@ -81,4 +122,3 @@
      */
     protected abstract void onValuesSelected(String facet, Collection<String> values, AjaxRequestTarget target);
-
 }
