wicket-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Grigorov <mgrigo...@apache.org>
Subject Re: How to add Java Script Confirmation dialog to dropdown choice
Date Mon, 25 Feb 2013 15:50:58 GMT
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 <heapifyman@gmail.com> wrote:

> Care to share this precondition handling?
>
>
> 2013/2/25 Martin Grigorov <mgrigorov@apache.org>
>
> > Hi,
> >
> >
> > On Mon, Feb 25, 2013 at 1:35 PM, heapifyman <heapifyman@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 <reiern70@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.boya@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-unsubscribe@wicket.apache.org
> > > > > For additional commands, e-mail: users-help@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/>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message