Now i've got it working with the quickstart and a simple ListView. Now i have
to find out the difference and why it is now working..,now working on
jetty...tomorrow i test it on Websphere...
Thanks!
public class HomePage extends WebPage {
private Contact selected = new Contact();
@SuppressWarnings("serial")
public HomePage(final PageParameters parameters) {
final WebMarkupContainer table = new
WebMarkupContainer("table");
PageableListView<Contact> listView = new
PageableListView<Contact>(
"contactrow", getContacts(), 4) {
@Override
protected ListItem<Contact> newItem(int index) {
ListItem<Contact> item = new
ListItem<Contact>(index,
getListItemModel(getModel(),
index)) {
@Override
protected void
onComponentTag(ComponentTag tag) {
super.onComponentTag(tag);
if (getModelObject() ==
selected) {
tag.put("class",
"selected");
}
}
};
return item;
}
@Override
protected void populateItem(final ListItem<Contact>
item) {
Contact contact = item.getModelObject();
final AjaxFallbackLink<Contact> contactDateLink
= new
AjaxFallbackLink<Contact>(
"link") {
@Override
public void onClick(AjaxRequestTarget
target) {
selected = (Contact)
getParent().getDefaultModelObject();
if (target != null) {
target.addComponent(table);
}
}
};
contactDateLink.add(new Label("linklabel",
contact.getContactDate().toString()));
item.add(contactDateLink);
item.add(new Label("code", contact.getCode()));
item.add(new Label("description",
contact.getDescription()));
}
};
table.setOutputMarkupId(true);
table.add(listView);
add(table);
add(new AjaxPagingNavigator("navigator", listView));
}
public static List<Contact> getContacts() {
List<Contact> resultList = new ArrayList<Contact>();
Contact contact = new Contact("A", new Date(), "description1");
resultList.add(contact);
contact = new Contact("B", new Date(), "description2");
resultList.add(contact);
contact = new Contact("C", new Date(), "description3");
resultList.add(contact);
contact = new Contact("D", new Date(), "description4");
resultList.add(contact);
return resultList;
}
}
@SuppressWarnings("serial")
class Contact implements Serializable {
private String code;
private Date contactDate;
private String description;
public Contact() {
super();
}
public Contact(String code, Date contactDate, String description) {
super();
this.code = code;
this.contactDate = contactDate;
this.description = description;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public Date getContactDate() {
return contactDate;
}
public void setContactDate(Date contactDate) {
this.contactDate = contactDate;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
<body>
<table wicket:id="table">
<tbody>
<tr>
<th style="width: 20px"></th>
<th style="width:
105px;">ContactDate</th>
<th>Description</th>
</tr>
<tr wicket:id="contactrow" bgcolor="#FFFFFF"
onmouseover="this.bgColor='gold';"
onmouseout="this.bgColor='#FFFFFF';">
<td>[code]</td>
<td> # [10/5/2010] </td>
<td>[desc]</td>
</tr>
</tbody>
</table>
<div id="navigator" wicket:id="navigator"></div>
</body>
--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/ListView-highlight-selected-row-tp2197486p2225237.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]