return uc.getOwner().getFirstname() + " " + uc.getOwner().getLastname(); //FIXME salutation
}
@Override
protected void populateItem(Item<UserContact> item) {
UserContact uc = item.getModelObject();
final long contactId = uc.getUserContactId();
final long userId = uc.getOwner().getUser_id();
if (uc.getPending()) {
item.add(AttributeModifier.append("class", "unread"));
}
item.add(new Label("name", getName(uc)));
item.add(new WebMarkupContainer("accept").add(new AjaxEventBehavior("onclick") {
private static final long serialVersionUID = 7223188816617664993L;
@Override
protected void onEvent(AjaxRequestTarget target) {
ContactsHelper.acceptUserContact(contactId);
updateContacts(target);
}
}).setVisible(uc.getPending()));
item.add(new WebMarkupContainer("decline").add(new AjaxEventBehavior("onclick") {
private static final long serialVersionUID = 1L;
@Override
protected void onEvent(AjaxRequestTarget target) {
getBean(UserContactsDao.class).deleteUserContact(contactId);
updateContacts(target);
}
}).setVisible(uc.getPending()));
item.add(new WebMarkupContainer("view").add(new AjaxEventBehavior("onclick") {
private static final long serialVersionUID = 1L;
@Override
protected void onEvent(AjaxRequestTarget target) {
d.open(target, userId);
}
}));
item.add(new WebMarkupContainer("message").add(new AjaxEventBehavior("onclick") {
private static final long serialVersionUID = 1L;
@Override
protected void onEvent(AjaxRequestTarget target) {
newMessage.reset(true).open(target, userId);
}
}).setVisible(!uc.getPending()));
item.add(new WebMarkupContainer("delete").add(new AjaxEventBehavior("onclick") {
private static final long serialVersionUID = 1L;
@Override
protected void onEvent(AjaxRequestTarget target) {
getBean(UserContactsDao.class).deleteUserContact(contactId);
updateContacts(target);
}
}).setVisible(!uc.getPending()));
}
};
updateContacts(null);
add(d, contacts.add(dw, pendingContacts, allContacts).setOutputMarkupId(true));//TODO update