All,

 

I'm trying implement a complicated inmethod DataGrid table and I would
like a sanity check as to the solution I came up with. The table is
multiple selectable, but in the case of the "name" column, I want to
have a hyperlink that forwards the user to a new view. In the case of
other columns I want the DataGrid to perform it's multiple selection as
normal.

 

The problem is that DataGrid's as far as I can see, only allows text
output for each cell, and don't allow you to render a new component such
as a panel or a link with a label.

 

I've attempted to intercept "cellClicked" method, but attempting to
redirect to a new view within that method causes a error in wicket.

 

I've thought about overriding "public Component newCell", but that never
gets called, and the IRenderable version of newCell isn't any use.

 

I've also tried to wrap WicketColumnAdapter and then use a standard
wicket PropertyColumn and the populateItem method to create a link with
a label, but as expected this fails as per the advice given in the
WicketColumnAdapter javadoc.

 

I've come up with this solution, but it seems like a horrific hack, and
I wonder if there isn't a better way of doing it, that makes more sense.
In all honesty, I totally chanced upon this solution;

 

 

columns.add( 

new WicketColumnAdapter( "displayName", 

              new
org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyCol
umn(

                     new Model<String>("name"), "surname", "
displayName"  ) ) {   

 

              @Override

              public Component newCell(WebMarkupContainer parent, String
componentId, IModel rowModel) {

 

                     Object object = rowModel.getObject();

 

                     LinkPanel panel = new LinkPanel( componentId,
object );

       

                     return panel; 

              }

       }

);

 

By wrapping a Wicket PropertyColumn in a WicketColumnAdaptor, the
newCell method on the adaptor gets called, and hence we can populate the
component.

 

Cheers,

Col.

 

 

Emap delivers intelligence, inspiration and access through publications, events 
and data businesses in retail, media, the public sector and the built 
environment. www.emap.com.

The information in or attached to this email is confidential and may be legally 
privileged. If you are not the intended recipient of this message any use, 
disclosure, copying, distribution or any action taken in reliance on it is 
prohibited and may be unlawful. If you have received this message in error, 
please notify the sender immediately by return email or by telephone on 
+44(0)207 728 5000 and delete this message and any copies from your computer 
and network. The Emap group does not warrant that this email and any 
attachments are free from viruses and accepts no liability for any loss 
resulting from infected email transmissions.

The Emap group reserves the right to monitor all e-mail communications through 
its networks. Please note that any views expressed in this email may be those 
of the originator and do not necessarily reflect those of the Emap group.

GroundSure Ltd. Company number 03421028 (England and Wales)
Emap Limited. Company number: 0537204 (England and Wales).
Registered Office: Greater London House, Hampstead Road, London NW1 7EJ, United 
Kingdom.
Details of the operating companies forming part of the Emap group can be found 
at www.emap.com

Reply via email to