abstract public class ClientSideEventBehavior extends AjaxEventBehavior { public ClientSideEventBehavior(String eventName) { super(eventName); }
@Override protected final void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.setAllowDefault(isDefaultAllowed()); String beforeHandler = getBeforeHandler(); AjaxCallListener listener = new AjaxCallListener(); listener.onBefore(beforeHandler); listener.onPrecondition("return false;"); attributes.getAjaxCallListeners().add(listener); } @Override public final void onEvent(AjaxRequestTarget) { // never called } protected boolean isDefaultAllowed() {return false;} abstract protected String getBeforeHandler(); } The user of this class can only use before handlers. On Mon, Feb 25, 2013 at 5:10 PM, heapifyman <heapify...@gmail.com> wrote: > Care to share this precondition handling? > > > 2013/2/25 Martin Grigorov <mgrigo...@apache.org> > > > Hi, > > > > > > On Mon, Feb 25, 2013 at 1:35 PM, heapifyman <heapify...@gmail.com> > wrote: > > > > > mydropdownComponent.add(new > AjaxFormComponentUpdatingBehavior("change") { > > > @Override > > > protected void onUpdate(AjaxRequestTarget target) { > > > target.appendJavaScript("your javascript..."); > > > } > > > }); > > > > > > > > In our project we have a ClientSideEventBehavior. It is a > AjaxEventBehavior > > with a precondition that always stops the Ajax call. > > > > > > > > > > 2013/2/25 Ernesto Reinaldo Barreiro <reier...@gmail.com> > > > > > > > Can you just register your "behavior" to on change? Something like: > > > > > > > > MyPanel extends Panel { > > > > > > > > > > > > public void renderHead(IHeaderResponse reponse) { > > > > > > > > > > > > > > > > > > > > > > reponse.render(OnDomReadyHeaderItem.forScript("jQuery('#mydropdown').on('change', > > > > function(){//what ever you want to do});")); > > > > > > > > } > > > > > > > > } > > > > > > > > On Mon, Feb 25, 2013 at 11:44 AM, venkat <venkatesh.b...@gmail.com> > > > wrote: > > > > > > > > > Hi , > > > > > > > > > > I have a requirement, where when user selects a particular option > > from > > > > > dropdown, I need to show Java Script Confirmation dialog. Is there > > any > > > > way > > > > > in Wicket to add javaScript behaviour to dropdown choice. > > > > > > > > > > Have used JavaScriptConfirmation to submit buttons in other areas > and > > > is > > > > > working fine,however am not sure how to add this behavior to > > > > dropdownchoice > > > > > events? > > > > > > > > > > I would appreciate quick response. > > > > > > > > > > Thanks > > > > > Venkat > > > > > > > > > > > > > > > > > > > > -- > > > > > View this message in context: > > > > > > > > > > > > > > > http://apache-wicket.1842946.n4.nabble.com/How-to-add-Java-Script-Confirmation-dialog-to-dropdown-choice-tp4656755.html > > > > > Sent from the Users forum mailing list archive at Nabble.com. > > > > > > > > > > > --------------------------------------------------------------------- > > > > > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > > > > > For additional commands, e-mail: users-h...@wicket.apache.org > > > > > > > > > > > > > > > > > > > > > > -- > > > > Regards - Ernesto Reinaldo Barreiro > > > > Antilia Soft > > > > http://antiliasoft.com/ <http://antiliasoft.com/antilia> > > > > > > > > > > > > > > > -- > > Martin Grigorov > > jWeekend > > Training, Consulting, Development > > http://jWeekend.com <http://jweekend.com/> > > > -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com <http://jweekend.com/>