Hi,
I'm tasked with upgrading an application from Wicket 7 to Wicket 9. There is one class with a heavy code smell: it relies on a Wicket internal realization. (Which promptly doesn't work any more in Wicket 9...) This email is part of my search for a better realization method. The use case: -- There is a form with lots of submit buttons. -- One button realizes a "show as pdf" functionality. -- The PDF shall be shown in a new tab. -- It shall be possible to use the button while still working on the form. This is a form submit -- the PDF shall show the then current content of the page. (Validation is not an issue in this case, the submit and form processing will succeed.) -- After showing a PDF representation of the form, it shall be possible to use the other buttons in this form, which are part of the HTML sequence of pages. I cannot use Javascript popups, as too many browsers block them. (In fact, my own developer browser blocks them. ;-)) So I need to have the following functionality for this button: -- Before the submit, a target attribute "_blank" get's added to the form. -- The form is submittet, by this button. (I.e., its onSubmit() must be called.) -- Afterwards, the target attribute is deleted from the form. The previous programmer in this project simply copied the Javascript code for an AjaxSubmitLink from Wicket 7 and enriched it with adding/deleting the form attribute. Not the smartest move, indeed; but it was working all this time I'm looking for best practice to achieve that functionality with the available Wicket API. I.e., I want to prepend and append Javascript to the Wicket-supplied submit functionality of a button or ajax submit action. I have looked at Javadoc and source code of the following classes (and their superclasses) and didn't found any hook/method where I can achieve my desired result: -- AjaxRequestAttributes: No methods to prepend/append JS code. -- AjaxSubmitLink: No methods to manipulate the emmitted JS code. -- AjaxFormSubmitBehavior: No methods to manipulate the emmitted JS code. -- Button: has getOnClickScript(), but this is empty. -- AjaxButton: doesn't redefine getOnClickScript(), so no gain to be get here either. FWIW: The application uses getCspSettings().blocking().disabled(). There's too much JS code in HTML that I don't want to touch in this round of update; that's a step after the Wicket 9 migration. Thus, currently I have no qualms to add JS code to HTML "onsubmit" attributes if that's the way to go at the moment. I'm looking for something like #prependJavaScript() and #appendJavaScript() in AjaxRequestTarget -- but not in the response handling, instead for the code that triggers the click event. tl;dr: How can I specify JS code that's executed before and after a (specific) button or ajax submit of a form? Here's hoping for some tips, Joachim -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Joachim Schrod, Roedermark, Germany Email: jsch...@acm.org --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org