You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Alec Swan <al...@gmail.com> on 2012/08/09 04:56:50 UTC

How to display a grid with empty cells

Hello,

I am using Wicket 1.4.17 and need to display a 3x3 table with all of
its cells, some of which may not have a model and hence blank. So, if
my DataProvider returns 0 elements than I want all 9 cells to be shown
as blank.

I started using GridView and overrode its populateEmptyItem() method
to display empty cells. However, contrary to its JavaDoc "Add
component to an Item for which there is no model anymore and is shown
in a cell" this method is not being called unless a row has at least
one item (see GrdiView#addItems()).

What would the easiest way to accomplish what I need without copying
the entire code from GridView class? Any other component that can do
that?

Thanks,

Alec

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How to display a grid with empty cells

Posted by Alec Swan <al...@gmail.com>.
I tried returning nulls for blank items from data provider but as you
said it feels like a hack because now my  GridView#populateItem()
needs to handle items with null model objects.

The way GridView behaves is confusing because it displays the entire
row of cells (some potentially blank) if the row has at least one
item. If the row has no items, then the row is not displayed. So,
GridView pads every row with empty cells but doesn't do this for every
column.

Should this be filed as a bug?

On Wed, Aug 8, 2012 at 9:37 PM, Bertrand Guay-Paquet
<be...@step.polymtl.ca> wrote:
> Hi,
>
> I haven't used the GridView directly so I can't help you with it
> specifically. However, have you considered modifying your provider to always
> return 9 records with some having an empty placeholder? It's definitely a
> "hack", but it may be worth a try.
>
> Bertrand
>
>
> On 08/08/2012 10:56 PM, Alec Swan wrote:
>>
>> Hello,
>>
>> I am using Wicket 1.4.17 and need to display a 3x3 table with all of
>> its cells, some of which may not have a model and hence blank. So, if
>> my DataProvider returns 0 elements than I want all 9 cells to be shown
>> as blank.
>>
>> I started using GridView and overrode its populateEmptyItem() method
>> to display empty cells. However, contrary to its JavaDoc "Add
>> component to an Item for which there is no model anymore and is shown
>> in a cell" this method is not being called unless a row has at least
>> one item (see GrdiView#addItems()).
>>
>> What would the easiest way to accomplish what I need without copying
>> the entire code from GridView class? Any other component that can do
>> that?
>>
>> Thanks,
>>
>> Alec
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


RE: How to display a grid with empty cells

Posted by Paul Bors <pa...@bors.ws>.
Make use of the EmptyPanel class for the null or empty models. You could
also simply call setVisible(false) on your component if you can hide it all
together.

http://wicket.apache.org/apidocs/1.4/org/apache/wicket/markup/html/panel/Emp
tyPanel.html

~ Thank you,
  Paul Bors

-----Original Message-----
From: Bertrand Guay-Paquet [mailto:bernie@step.polymtl.ca] 
Sent: Wednesday, August 08, 2012 11:37 PM
To: users@wicket.apache.org
Subject: Re: How to display a grid with empty cells

Hi,

I haven't used the GridView directly so I can't help you with it
specifically. However, have you considered modifying your provider to always
return 9 records with some having an empty placeholder? It's definitely a
"hack", but it may be worth a try.

Bertrand

On 08/08/2012 10:56 PM, Alec Swan wrote:
> Hello,
>
> I am using Wicket 1.4.17 and need to display a 3x3 table with all of 
> its cells, some of which may not have a model and hence blank. So, if 
> my DataProvider returns 0 elements than I want all 9 cells to be shown 
> as blank.
>
> I started using GridView and overrode its populateEmptyItem() method 
> to display empty cells. However, contrary to its JavaDoc "Add 
> component to an Item for which there is no model anymore and is shown 
> in a cell" this method is not being called unless a row has at least 
> one item (see GrdiView#addItems()).
>
> What would the easiest way to accomplish what I need without copying 
> the entire code from GridView class? Any other component that can do 
> that?
>
> Thanks,
>
> Alec
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How to display a grid with empty cells

Posted by Bertrand Guay-Paquet <be...@step.polymtl.ca>.
Hi,

I haven't used the GridView directly so I can't help you with it 
specifically. However, have you considered modifying your provider to 
always return 9 records with some having an empty placeholder? It's 
definitely a "hack", but it may be worth a try.

Bertrand

On 08/08/2012 10:56 PM, Alec Swan wrote:
> Hello,
>
> I am using Wicket 1.4.17 and need to display a 3x3 table with all of
> its cells, some of which may not have a model and hence blank. So, if
> my DataProvider returns 0 elements than I want all 9 cells to be shown
> as blank.
>
> I started using GridView and overrode its populateEmptyItem() method
> to display empty cells. However, contrary to its JavaDoc "Add
> component to an Item for which there is no model anymore and is shown
> in a cell" this method is not being called unless a row has at least
> one item (see GrdiView#addItems()).
>
> What would the easiest way to accomplish what I need without copying
> the entire code from GridView class? Any other component that can do
> that?
>
> Thanks,
>
> Alec
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org