heh, you see...all those hacks like calling isvisible inside
getrowcount() were to avoid all these extra calls to size()...so more
hacks to avoid other hacks, etc.

we need to rethink how the whole size() thing is dealt with

-igor


On Dec 10, 2007 10:41 AM, Michael Sparer <[EMAIL PROTECTED]> wrote:
>
> 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]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to