The basic tool of re-use is the Panel. You can define a Panel subclass whose constructor takes a User object. Then within the HTML for the list you would have a <span> with a wicket:id for the panel which gets repeated, rather than a wicket:id for each user.property.
In your Java code, your ListView's populateItem() method would have a single line to instantiate and add a single User panel. (There might be a way to reduce the overhead of this solution by using the Fragment class instead of Panel, but as a newbie myself, I was unable to understand Fragment's JavaDoc, and I don't think the wicket-examples use it.) -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Wednesday, March 08, 2006 3:57 PM To: wicket-user@lists.sourceforge.net Subject: [Wicket-user] Wicket newbie - Duplicate code - what am I doing wrong? Dear Wicket, I've just started to look at Wicket so I apologize if this is a complete newbie question. I've searched the docs but haven't found an answer to my question, so I was hoping you could help. Briefly, I have a List of POJOs which I want to display. Do I really have to do this? (In Java code) add(new ListView("users", view.getUsers()) { public void populateItem(final ListItem p_item) { final User user = (User) p_item.getModelObject(); p_item.add(new Label("username", user.getUsername())); p_item.add(new Label("password", user.getPassword())); } }); (In HTML template) <tr wicket:id="users"> <td><span wicket:id="username"></span></td> <td><span wicket:id="password"></span></td> </tr> Every time I add a property to my User POJO, I have to add a line of code in the Java code *and* in the HTML template. This violates the DRY principle in my book. Isn't there a way to bind a POJO directly and then access its properties in the HTML template in a OGNL/FreeMarker/etc. type of way? Many thanks for your help! Fred -- [EMAIL PROTECTED] ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642 _______________________________________________ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user