Hi, There are three types of HTML buttons: submit, reset and button. You need the third one: <button type="button">Like Link</button>. See http://www.w3schools.com/tags/att_button_type.asp
Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Thu, Jul 10, 2014 at 4:03 AM, Garret Wilson <gar...@globalmentor.com> wrote: > Everyone, > > There needs to be a way to have a Button that does not perform an HTML > submit, such as Link, which allows onClick() handling instead of onSubmit(). > > Your first response will probably tell me to RTFM and > setDefaultFormProcessing(false). :) But hear me out. If I have a submit > button <button wicket:id="cancel" type="submit"...> in the HTML, and set an > <input> as required in the HTML, then modern browsers will be so nice as to > pop up a little flyover bubble pointing right at the field in question, and > say, "You need to fill in this field." The problem is that the cancel > button <button wicket:id="cancel" type="submit"...> will also cause this > browser response, even with setDefaultFormProcessing(false) in the code, > because the browser does this validation before submission even occurs. > > I can short-circuit browser validation on cancellation by using <button > wicket:id="cancel" type="reset"...> in the HTML, but then my > Button.onSubmit() code in Java won't get called! > > I can work around this by using Link in the code instead of Button, using > <button> with type="reset" in the HTML, and overriding onClick() in the > Java code. But it seems strange (and semantically silly) to use a Button in > one instance and Link in another, just to get different submit > activity---that is, unless all Wicket Buttons are really SubmitButtons. > > In fact, that's what I'm getting to: a Button is a button, and it should > have an onClick() method just like a link. Only a specialized SubmitButton > should have an onSubmit(). A normal Button shouldn't cause automatic > submission of the form just because I used a Button instead of a Link. > > You may say that I should turn off required in the HTML so as to disable > all browser validation, and let Wicket take care of all validation for > consistency. There is some validity to this, but the flyover notifications > the browser uses for empty required fields are so pretty and so much more > user-friendly... > > Garret > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >