You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by jchappelle <jc...@4redi.com> on 2009/04/02 16:48:21 UTC

Re: Adding multiple ajax behaviour on same event

I am also having the same problem with CompositeBehavior. I am using wicket
1.3.4 and I copied the code from the following wiki:
http://cwiki.apache.org/WICKET/composite-behaviors.html. I had to make some
slight modifications. 

It looks like the RequestCycle.urlFor(...) method needs to know the index of
the behavior within the components list of behaviors in order to generate
the url for an Ajax behavior. I guess it puts that index in the url for
lookup when the request is made. If it is not in the components list it will
throw an exception. In the case of the CompositeBehavior it is not. 

Could someone please help us?

Thanks,

Josh


Raghav@directi wrote:
> 
> I am using an AjaxLink which has a javascript for onclick event now i want
> to add AjaxFormValidatingBehavior  to this link on the same event
> "onclick" ...i tried adding the same...but the link does not  work
> properly...i think the actual javascript is replaced....can any one please
> help me how to do this...
> 
> I had a look at IAjaxCallDecorator ...... If i hv understood
> IAjaxCallDecorator  correctly i can use it to append to the
> javascript....so one way could be to have a look at the javascript
> generated by AjaxFormValidatingBehavior   and append it to the javascript
> of ajaxlink.....but is there a cleaner way to do this......
> 
> Also found something called CompositeBehavior in
> wicketstuff-core-misc.....but it does not
> seem to be working....may be i din get how to use it......
> 
> this is what i m trying to do
> 
> 
> new AjaxFallbackLink("checkAvailablity") {
> 
>                {
>                    final AjaxFormValidatingBehavior
> ajaxFormValidatingBehavior = new AjaxFormValidatingBehavior(Form.this,
> "onclick") {
>                        @Override
>                        protected void onError(AjaxRequestTarget target) {
>                           // add components to target
>                        }
> 
>                        @Override
>                        protected void onSubmit(AjaxRequestTarget target) {
>                         // add components to target
>                        }
>                    };
>                    final CompositeBehavior behavior = new
> CompositeBehavior(ajaxFormValidatingBehavior);
>                    add(behavior);
>                }
> 
>                @Override
>                public void onClick(final AjaxRequestTarget target) {
>                  // do smthing
>                }
>            }
> 
> But when i did this i got this exception trace...........
> 
> Behavior [RequestCycle@1feffac thread=btpool0-2] was not registered
> with this component: [MarkupContainer [Component id =
> checkAvailablity,......
>     at org.apache.wicket.RequestCycle.urlFor(RequestCycle.java:789)
>     at org.apache.wicket.Component.urlFor(Component.java:3124)
>     at
> org.apache.wicket.behavior.AbstractAjaxBehavior.getCallbackUrl(AbstractAjaxBehavior.java:123)
>     at
> org.apache.wicket.behavior.AbstractAjaxBehavior.getCallbackUrl(AbstractAjaxBehavior.java:92)
>     at
> org.apache.wicket.ajax.form.AjaxFormSubmitBehavior.getEventHandler(AjaxFormSubmitBehavior.java:98)
>     at
> org.apache.wicket.ajax.AjaxEventBehavior.onComponentTag(AjaxEventBehavior.java:108)
>     at
> org.apache.wicket.behavior.AbstractAjaxBehavior.onComponentTag(AbstractAjaxBehavior.java:132)
>     at
> org.wicketstuff.misc.behaviors.CompositeBehavior.onComponentTag(CompositeBehavior.java:55)
>     at org.apache.wicket.Component.renderComponentTag(Component.java:3815)
>     at org.apache.wicket.Component.renderComponent(Component.java:2469)
>     at
> org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1411)
>     at org.apache.wicket.Component.render(Component.java:2315)
>     at
> org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1297)
>     at
> org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1476)
> 
> 
> Can anyone please help..... I need to get this working asap.....
> 
> 

-- 
View this message in context: http://www.nabble.com/Adding-multiple-ajax-behaviour-on-same-event-tp22181080p22849658.html
Sent from the Wicket - User 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