Thank you! Your solution is really nice. It functions well!
I have a problem which the datagrid. After removing a row in the database it throws an exception, because wicket is unable to populate an item (I assume the deleted one) How can I tell wicket to reload the datagrid because something in the DB changed. ----- Ursprüngliche Mail ---- Von: Linda van der Pal <[email protected]> An: [email protected] Gesendet: Mittwoch, den 30. September 2009, 11:43:40 Uhr Betreff: Re: How would you realize a "delete"-Link in a datagrid row? 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: [email protected] > For additional commands, e-mail: [email protected] > ------------------------------------------------------------------------ > > > 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: [email protected] For additional commands, e-mail: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
