Hi,
I'm using a DataView along with a AjaxPagingNavigator inside a
wicket:enclosure tag. I wanted to display the whole stuff only if the
item-count of the items that will be displayed in the DataView is greater
than 0.
I wanted to avoid by all means (well it would have been the last resort
actually :-)) to call the DataProvider's size-method as this would make an
unnecessary database query. Fortunately the DataView provides a method
getRowCount() which should give me exactly the number I need, and write it
to its iternal cache.
So I overrode the DataView's isVisible method like that
public boolean isVisible() {
return getRowCount() > 0;
}
Unfortunately getRowCount() calls isVisible() internally which then leads to
an infinite loop. To keep it short, I ended up with a filthy hack by
implementing a custom subclass of DataView that went like that in the
constructor:
private boolean _initActive = false;
private int _rowCount;
public MyDataView(....) {
super(...);
_initActive = true;
_rowCount = getRowCount();
_initActive = false;
}
public boolean isVisible() {
return _initActive || _rowCount > 0;
}
My question: As empty PagingNavigators/Dataviews often don't look nice, I
can imagine that keeping them invisible if they're empty is a common
scenario. Wouldn't it be nice to have a convenience method in DataView or
PagingNavigator for that?
Or am I missing an obvious way to do this?
-----
Michael Sparer
http://talk-on-tech.blogspot.com
--
View this message in context:
http://www.nabble.com/enclosures-and-dataview-tp14258879p14258879.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]