In the book Wicket in Action I found this example:
public class MyPage extends WebPage {
public MyPage() {
Link link = new Link("link") {
@Override
protected void onClick() {
System.out.println("Link clicked");
}
};
add(link);
link.add(new SimpleAttributeModifier("onclick",
"return confirm('Are you sure?');");
}
}
I tried to copy this behavior in my own code, but for some reason, it
does show the popup, but then doesn't go on to actually going through
with the action (deleting an item) after confirmation.
So here's my code:
private Link<?> createDeleteButton(final ListItem<BookListData> item) {
Link<?> deleteButton = new DeleteLink("delete", item.getModel());
deleteButton.add(new Image("deleteIcon", new
ResourceReference(BookListPanel.class, "../icons/list-remove.png")));
deleteButton.add(new SimpleAttributeModifier("onclick", "return
confirm('Are you sure?');"));
return deleteButton;
}
// This is an inner class in the same class as the method above
@AuthorizeAction(action = Action.ENABLE, roles = { "OWNER" })
private class DeleteLink extends Link<BookListData> {
private static final long serialVersionUID = 1L;
public DeleteLink(final String id, final IModel<BookListData>
model) {
super(id, model);
}
@Override
public void onClick() {
// delete the book
try {
BookSaver bs = new BookSaver();
BookListData deletedbook = (BookListData) getModelObject();
bs.deleteBook(deletedbook.getIsbn());
booklistmodel.getObject().remove(deletedbook);
} catch (SQLException se) {
error(SQLERROR_GET+ '\n' + se.getMessage());
} catch (IOException ie) {
error(IOERROR+ '\n' + ie.getMessage());
}
}
}
Any clue what I might be doing wrong?
Regards,
Linda
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]