Here is the quick and dirty solution. Is there enough interest to build a
full blown grid component?

                final int cols=7;
                final int rowsPerPage=5;
                add(new PageableDataView("grid", new ContactDataProvider(),
cols*rowsPerPage) {
                        
                        protected void populateItem(final DataItem item)
                        {
                                Contact
contact=(Contact)item.getModelObject();
                                item.add(new Label("cell",
contact.getFirstName()+" "+contact.getLastName()));
                        }
                        
                        protected void renderItem(Component item)
                        {
                                        DataItem di=(DataItem)item;
                                        
                                        if (di.getIndex()%cols==0)
getResponse().write("<tr>");
                                        super.renderItem(item);
                                        
                                        if (di.getIndex()+1==getItemCount())
{
                                                if (getItemCount()%cols!=0)
{
                                                        int
needed=cols*((getItemCount()/cols)+1)-getItemCount();
        
getResponse().write("<td colspan=\""+needed+"\">&nbsp;</td>");
                                                }
                                        }
                
                                        
                                        if ((di.getIndex()+1)%cols==0)
getResponse().write("</tr>");
                        }
                        
                });

---------------

<table cellspacing="0" class="dataview" border="1">
        <span wicket:id="grid">
                <td><span wicket:id="cell">[cell]</span></td>
        </span>
</table>


-Igor




> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Gili
> Sent: Friday, August 12, 2005 7:44 AM
> To: [EMAIL PROTECTED]
> Subject: [Wicket-user] PageableDataView and column cells
> 
> Hi,
> 
>       I'm trying to display a grid of images, for example 4 
> columns and 3 rows of images, where each "cell" is a 
> different entry retrieved from the database with a different index/id.
> 
>       I took a look at the DisplayTag example and 
> PageableDataView's source-code and they don't seem to be 
> quite appropriate for handling my use-case. In a nutshell, 
> PageableDataView only has a concept of rows, where the 
> populateItem(ListView) method allows one to add() different 
> views of the same database row. So for example, a given row 
> will have an id, name, description, etc...
> 
>       What I need is multiple columns per visual row where 
> each column is a distinct DB item, with a distinct ID. 
> PageableDataView only increments the index outside the scope 
> of populateItem() so I'm not sure it's possible to implement using it.
> 
>       My gut feeling is that maybe I can use PageableDataView 
> with CSS somehow to emulate columns but i would be much nicer 
> if I just had a component that had the concept of columns in 
> the first place.
> 
>       What do you think?
> 
> Thank you,
> Gili
> --
> http://www.desktopbeautifier.com/
> 
> 
> -------------------------------------------------------
> SF.Net email is Sponsored by the Better Software Conference & EXPO
> September 19-22, 2005 * San Francisco, CA * Development 
> Lifecycle Practices
> Agile & Plan-Driven Development * Managing Projects & Teams * 
> Testing & QA
> Security * Process Improvement & Measurement * 
> http://www.sqe.com/bsce5sf
> _______________________________________________
> Wicket-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/wicket-user
> 
> 
> 




-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to