I created a deteletButton as follows. I have a DeleteButton innerclass,
and a method that adds this button to the panel that is shown in the table.
private class DeleteButton extends Button {
private static final long serialVersionUID = 1L;
public DeleteButton(final String id, final IModel<String> model) {
super(id, model);
}
@Override
public void onSubmit() {
try {
deleteData((String) getModelObject()); // a method that
does the actual data deletion in the database
} catch (SQLException se) {
error(StringResources.SQLERROR_GET + '\n' +
se.getMessage());
} catch (IOException ie) {
error(StringResources.IOERROR + '\n' + ie.getMessage());
}
}
@Override
public boolean isEnabled() {
return isEditingAuthorised();
}
}
private void addDeleteLink(final IModel<?> model) {
String id = (String)getIdFromModel(model); // a method that
extracts the id from the model (based on what kind of class is in the model)
Button deleteButton = new DeleteButton("delete", new
Model<String>(id));
deleteButton.add(new Image("deleteIcon", new
ResourceReference(EmptyIconReference.class, "list-remove.png")));
deleteButton.add(new SimpleAttributeModifier("onclick",
"return confirm('Are you sure?');"));
add(deleteButton);
}
I hope this helps.
Regards,
Linda
Peter Arnulf Lustig wrote:
Hi,
I'd like to create a delete link where you can delete a row in a datagrid. But when you
click on the delete link, the delete label should change and a warning occurs: "Do
you really want to delete xyz".
After the second click it finally deletes the content.
How can I achieve that? Could you verbalize the procedure?
Thanks!!
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org
------------------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.409 / Virus Database: 270.13.115/2404 - Release Date: 09/30/09 05:52:00
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org