HTML for the panel ((ContactPanel.html): <html xmlns:wicket> <wicket:panel> <table> <tr> <td><span wicket:id="nameLabel"></span></td> <td><span wicket:id="name"></span></td> </tr> <tr> <td><span wicket:id="userNameLabel"></span></td> <td><span wicket:id="userName"></span></td> </tr> <tr> <td><span wicket:id="phoneLabel"></span></td> <td><span wicket:id="phone"></span></td> </tr> <tr> <td><span wicket:id="emailLabel"></span></td> <td><span wicket:id="email"></span></td> </tr> </table> </wicket:panel> </html>
Java code for the panel (ContactPanel.java): public class ContactPanel extends Panel { private static final long serialVersionUID = 1L; public ContactPanel(String id, IModel model) { super(id, model); add(new Label("nameLabel", new ResourceModel("nameLabel"))); add(new Label("name")); add(new Label("userNameLabel", new ResourceModel("userNameLabel"))); add(new Label("userName")); add(new Label("phoneLabel", new ResourceModel("phoneLabel"))); add(new Label("phone")); add(new Label("emailLabel", new ResourceModel("emailLabel"))); add(new Label("email")); } } HTML for the page using the panel (VacanyPage.html): --- snip --- <table> <tr> <td><span wicket:id="hrContactPanel"></span></td> </tr> <tr> <td><span wicket:id="hiringManagerPanel"></span></td> </tr> </table> --- snip --- Java code for the page (VacanyPage.java): --- snip --- Form form = new Form("vacancyForm", new CompoundPropertyModel(vacancyReq)) { --- snip --- Contact hrContact = new Contact(); form.add(new ContactPanel("hrContactPanel", new CompoundPropertyModel(hrContact))); Contact hiringManager = new Contact(); form.add(new ContactPanel("hiringManagerPanel", new CompoundPropertyModel(hiringManager))); --- snip --- Properties file for the page (VacancyPage.properties): vacancyForm.hrContactPanel.nameLabel=HR Contact: vacancyForm.hrContactPanel.userNameLabel=HR Contact Username: vacancyForm.hrContactPanel.phoneLabel=Phone: vacancyForm.hrContactPanel.emailLabel=Email: vacancyForm.hiringManagerPanel.nameLabel=Hiring Manager: vacancyForm.hiringManagerPanel.userNameLabel=Hiring Manager Username: vacancyForm.hiringManagerPanel.phoneLabel=Phone: vacancyForm.hiringManagerPanel.emailLabel=Email: As you can see from the code the VacancyPage has two instances of ContactPanel and these should have different labels. I have tried different ways to specify this, but Wicket says it cannot find the labels, so I must be doing something wrong. Thanks in advance for any help! Best Regards, /Peter 2008/6/11 Martin Makundi <[EMAIL PROTECTED]>: > Can you paste the code for better insight into your problem? > > 2008/6/11 Peter Eriksson <[EMAIL PROTECTED]>: > > Hello, > > > > I have just begun to use wicket and so far I am very impressed with the > > framework. > > I have a question about best practice to solve a problem. I have a > component > > (wicket panel) that contain contact information (like name, address, > email, > > phone, etc) and on a specific web page I want to have two of the contact > > panels. They of course access different model fields. Now to the > question: > > The labels used for the contact fields are slightly different, so the > > question is how to best solve this? Since the labels are not the same for > > the two contact panels I cannot use a ResourceModel as it is because then > > they would have the same label text. Is the best way to solve this with > > inheritence or do you have any other solution? > > > > Best Regards, > > /Peter > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >