Search in sources :

Example 1 with ISortState

use of org.apache.wicket.extensions.markup.html.repeater.data.sort.ISortState in project midpoint by Evolveum.

the class TableHeadersToolbar method newSortableHeader.

@Override
protected WebMarkupContainer newSortableHeader(String headerId, final String property, final ISortStateLocator locator) {
    return new AjaxFallbackOrderByBorder(headerId, property, locator) {

        @Override
        protected void onSortChanged() {
            getTable().setCurrentPage(0);
        }

        @Override
        protected void onAjaxClick(AjaxRequestTarget target) {
            target.add(getTable());
        }

        @Override
        public void onComponentTag(ComponentTag tag) {
            super.onComponentTag(tag);
            ISortState sortState = locator.getSortState();
            SortOrder dir = sortState.getPropertySortOrder(property);
            String cssClass;
            if (dir == SortOrder.ASCENDING) {
                cssClass = "sortable asc";
            } else if (dir == SortOrder.DESCENDING) {
                cssClass = "sortable desc";
            } else {
                cssClass = "sortable";
            }
            if (!Strings.isEmpty(cssClass)) {
                tag.append("class", cssClass, " ");
            }
        }
    };
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ComponentTag(org.apache.wicket.markup.ComponentTag) SortOrder(org.apache.wicket.extensions.markup.html.repeater.data.sort.SortOrder) AjaxFallbackOrderByBorder(org.apache.wicket.extensions.ajax.markup.html.repeater.data.sort.AjaxFallbackOrderByBorder) ISortState(org.apache.wicket.extensions.markup.html.repeater.data.sort.ISortState)

Aggregations

AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 AjaxFallbackOrderByBorder (org.apache.wicket.extensions.ajax.markup.html.repeater.data.sort.AjaxFallbackOrderByBorder)1 ISortState (org.apache.wicket.extensions.markup.html.repeater.data.sort.ISortState)1 SortOrder (org.apache.wicket.extensions.markup.html.repeater.data.sort.SortOrder)1 ComponentTag (org.apache.wicket.markup.ComponentTag)1