Hi, You already wrap the call to wicketAjaxXXX() method in if statement. Just raise a flag that you entered in this code and set it back to false in the success/failure handler.
On Wed, Sep 5, 2012 at 3:40 PM, Marco Di Sabatino Di Diodoro <marco.disabat...@tirasa.net> wrote: > Hi Martin, > > On Sep 5, 2012, at 12:20 PM, Martin Grigorov wrote: > >> Hi Marco, >> >> I see a quite simple solution with Wicket 6 for this. I think you just >> start with your project (or even this is just a prototype?) so you >> better use "the latest and greatest" :-) > > We can not upgrade to Wicket 6 in this moment. > >> >> What I mean is to use the new AjaxChannel.Type.Active. The active type >> prevents a second Ajax call in the same channel while there is a still >> running Ajax call in this channel. >> >> The code is as simple as: >> >> @Override >> protected void updateAjaxAttributes(AjaxRequestAttributes attrs) { >> super.updateAjaxAttributes(attrs); >> >> attrs.setAjaxChannel(new AjaxChannel("modalClose", Type.Active)); >> } >> >> For more about the goodies in Wicket 6 read: >> http://wicketinaction.com/2012/07/wicket-6-javascript-improvements/ >> >> In Wicket 1.5 you will have to add some custom JavaScript to prevent >> the second request. You can unbind the event, or add a flag for >> example. > > I tried to use unbind() and flag but always return me the same error. How can > I prevent the second request? > > Thanks > Marco > >> >> On Wed, Sep 5, 2012 at 12:04 PM, Marco Di Sabatino Di Diodoro >> <marco.disabat...@tirasa.net> wrote: >>> Hi all, >>> >>> I configure into Apache Syncope the possibility to close ModalWindow with >>> ESC key press event. >>> >>> public class CloseOnESCBehavior extends AbstractDefaultAjaxBehavior { >>> >>> private static final long serialVersionUID = 5826308247642534260L; >>> private ModalWindow modalWindow; >>> >>> public CloseOnESCBehavior(ModalWindow modalWindow) { >>> this.modalWindow = modalWindow; >>> } >>> >>> private static final String PRE_JS = "$(document).ready(function() {\n" >>> + "$(document).bind('keyup', function(evt) {\n" >>> + " if (evt.keyCode == 27){\n"; >>> >>> private static final String POST_JS = "\n evt.preventDefault();\n" >>> + "evt.stopImmediatePropagation();\n" >>> + " }\n" >>> + " });\n" >>> + "});"; >>> >>> @Override >>> protected void respond(final AjaxRequestTarget target) { >>> modalWindow.close(target); >>> } >>> >>> @Override >>> protected String findIndicatorId() { >>> return null; >>> } >>> >>> @Override >>> public void renderHead(final Component component, final IHeaderResponse >>> response) { >>> response.renderJavaScript(new >>> StringBuilder(PRE_JS).append(getCallbackScript()) >>> .append(POST_JS).toString(), >>> "closeModalOnEsc"); >>> } >>> >>> In the modal page: >>> >>> add(new CloseOnESCBehavior(window)); >>> >>> It work correctly with Chrome and Safari. With Firefox, if I press the ESC >>> key twice quickly before the window closes the console return an error: >>> >>> ERROR: Wicket.Ajax.Call.failure: Error while parsing response: Could not >>> find root <ajax-response> element >>> >>> Regards >>> Marco >>> >>> >>> -- >>> >>> Dott. Marco Di Sabatino Di Diodoro >>> Tel. +39 3939065570 >>> >>> Tirasa S.r.l. >>> Viale D'Annunzio 267 - 65127 Pescara >>> Tel +39 0859116307 / FAX +39 0859111173 >>> http://www.tirasa.net >>> >>> Apache Syncope PPMC Member >>> http://people.apache.org/~mdisabatino >>> >>> >>> >>> >> >> >> >> -- >> Martin Grigorov >> jWeekend >> Training, Consulting, Development >> http://jWeekend.com >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org >> For additional commands, e-mail: users-h...@wicket.apache.org >> > > -- > > Dott. Marco Di Sabatino Di Diodoro > Tel. +39 3939065570 > > Tirasa S.r.l. > Viale D'Annunzio 267 - 65127 Pescara > Tel +39 0859116307 / FAX +39 0859111173 > http://www.tirasa.net > > Apache Syncope PPMC Member > http://people.apache.org/~mdisabatino > > > > -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org