Florian Hehlen wrote:
> HI all,
> 
> I am sad to announce that my company did not choose to use wicket after 
> comparison with struts 2. :-(
> 
> One criticism that came out as we were looking at Wicket code was that 
> there seems to be a need to write a lot of Java code in a ListView for 
> such things as displaying a table. Although I did not see this issue as 
> out-weighing all the benefits, many of my colleagues did.
> 
> Is there any plan or push or hidden feature that allows for a bean to be 
> directly mapped to a template without having to declare new Label(...) 
> for each field in the ListView. I think this would be a great win for 
> Wicket if adding those low-level components was only necessary when one 
> wants to add special handling, formating, validation, etc.

You evidently haven't researched enough, or you'd have realised that 
it's trivially easy to create a set of components completely tailored to 
your project/company's specific needs, that you can just reuse it across 
your project(s) with a few lines of code.

In anything other than a trivially small project, if you're still 
thinking in terms of wiring in Labels manually for most listing jobs, 
you've completely missed the point.

It's really easy (less than a day, less than an hour if you're good) to 
create something that works like this, for example:

DaoDataTable table = new DaoDataTable(myDao, myCriteria);
table.addColumn("name");
table.addColumn("description");
table.addColumn(new IconLinkColumn(ResourceReference icon, String 
altTitleMessageKey) {
     public void onClick(Object bean) {
         // Do foo.
     }
});

public class EditColumn extends IconLinkColumn {
     public EditColumn() {
         super(Icons.EDIT, getString("edit"));
     }
}

etc., etc.

Nest a ListView "columns" inside another ListView "rows". Put your 
dataset in the "rows" model, and your columns added above in the 
"columns" model. Inside the "columns" populateItem(), add a Label if you 
have a TextColumn, and a Link for the edit stuff. For icons, you can 
embed a tiny fragment with an image nested inside a link.


You can then trivially build a higher-level component that embeds the 
table along with a paging navigator and a search field or whatever you 
like (provided your criteria and/or DAO implement some kind of common 
interface to let you do that).

It's useless me just giving you the code for this, as you'd need to 
structure your DAOs and Criteria stuff the same way as us. And /that/ is 
the reason we don't provide a base component like this in the core 
library - everyone wants to do things in slightly different ways.

For CRUD apps, there isn't a one-size-fits-all, as witnessed by how 
utterly useless Ruby on Rails' scaffolding is for real production code.

However, the above code is only a couple of hundred lines, and is 
reusable across our whole organisation, provided everyone structures 
their DAOs in the same way. If they didn't, we could come up with a 
slightly less one-size-fits-all way of doing things, but that'd be more 
code each time to tie the data layer in appropriately.

If you wanted to, you could even apply annotations to your beans, which 
this code could use. So you could have @Editable on the class, and 
@ViewInList on the methods you wish to automatically add.

Maybe we should include something like this in wicket-examples. People 
just don't seem to appreciate how easy it is to write this stuff.

Al
-- 
Alastair Maw
Wicket-biased blog at http://herebebeasties.com

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to