I've put it on a button, might that be why it doesn't work?

Generated line of source code:

<button type="submit" wicket:id="delete" class="greenButton" onclick="return confirm('Are you sure?');"><img 
wicket:id="deleteIcon" src="resources/nl.lunaris.bookdb.webui.pages.BookListPanel/null/icons/list-remove.png"/></button>


Jeremy Thomerson wrote:
What's the generated JS?  Have you debugged with Firebug, etc, to see what's
happening in the JS?  Are you attaching that link to a regular anchor tag in
the HTML?  If you're putting it on a span, Wicket will generate an onclick
to make it a link - which may iinterfere with your onclick JS.

--
Jeremy Thomerson
http://www.wickettraining.com



On Fri, Apr 10, 2009 at 3:38 AM, Linda van der Pal <
lvd...@heritageagenturen.nl> wrote:

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: 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.287 / Virus Database: 270.11.51/2052 - Release Date: 04/10/09 06:39:00



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to