Monday, February 04, 2008

Wicket IndicatingOrderByBorder component

Wicket have form components that displays a busy icon (like progress bar) whenever a button is clicked. They are the IndicatingAjaxButton, IndicatingAjaxFallbackLink, IndicatingAjaxLink and IndicatingAjaxSubmitButton objects.

What is not provided though is the indicating orderByBorder component. What is OrderByBorder in the first place? It's a component to use, if you want to sort your SortableDataProvider component.

Using the api OrderByBorder does the job well if your data is not big. But if you are sorting huge amount of data, its better to "Ajaxify" it. (For more information about Sorting Data View you can read it here: http://wicketstuff.org/wicket13/repeater/ ).

Here's the customize code for making your own Ajax OrderByBorder:


class IndicatingOrderByBorder extends AjaxFallbackOrderByBorder implements IAjaxIndicatorAware {

private final WicketAjaxIndicatorAppender indicatorAppender = new WicketAjaxIndicatorAppender();
private Form contactListForm;

public IndicatingOrderByBorder(String id, String property, ISortStateLocator
stateLocator, DataView dataView, Form contactListForm) {
super(id, property, stateLocator);
this.contactListForm = contactListForm;
add(indicatorAppender);
}

@Override
protected void onAjaxClick(AjaxRequestTarget target) {
target.addComponent(contactListForm);
}

public String getAjaxIndicatorMarkupId() {
return indicatorAppender.getMarkupId();
}
}


To learn that basic, you can read these books:
1) Pro Wicket
2) Wicket In Action (release date: July 2008)

No comments: