Hi,

when I want to manage the 'before' and 'complete' handlers of an ajax
component, everything works as expected if I override the component
updateAjaxAttributes method of the component like in the below example:

public class HomePage extends WebPage {
        public HomePage(final PageParameters parameters) {
                super(parameters);

                

                final AjaxLink<String> link = new
AjaxLink<String>("submit",Model.of("link"))
                {
                        
                        @Override
                        public void onClick(AjaxRequestTarget target)
                        {
                                
                                
                        }
                        
                        @Override
                        protected void 
updateAjaxAttributes(AjaxRequestAttributes attributes)
                        {
                                super.updateAjaxAttributes(attributes);
                                IAjaxCallListener listener = new 
IAjaxCallListener()
                              {

                                        @Override
                                        public CharSequence 
getBeforeHandler(Component component)
                                        {
                                                return "alert('Before');";
                                        }

                                        ...

                                        @Override
                                        public CharSequence 
getCompleteHandler(Component component)
                                        {
                                                return "alert('Complete');";
                                        }
                               
                              };
                         
                              attributes.getAjaxCallListeners().add(listener);
                        }
                };
                
                
                add(link);

    }
}

on the other hand, if I create an AbstractDefaultAjaxBehavior, override
updateAjaxAttributes, and attach it to the component, the two handlers are
not invoked:

public class HomePage extends WebPage {
        public HomePage(final PageParameters parameters) {
                super(parameters);

                

                final AjaxLink<String> link = new
AjaxLink<String>("submit",Model.of("link"))
                {
                        
                        @Override
                        public void onClick(AjaxRequestTarget target)
                        {
                                
                                
                        }
                        
                        
                };
                
                link.add(new SomeAjaxBehavior());
                
                add(link);

    }
}


// SomeSomeAjaxBehavior
public class SomeAjaxBehavior extends AbstractDefaultAjaxBehavior
{

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes)
        {
                // TODO Auto-generated method stub
                super.updateAjaxAttributes(attributes);
                 IAjaxCallListener listener = new IAjaxCallListener()
              {

                        @Override
                        public CharSequence getBeforeHandler(Component 
component)
                        {
                                return "alert('Before');";
                        }

                        ...

                        @Override
                        public CharSequence getCompleteHandler(Component 
component)
                        {
                                return "alert('Complete');";
                        }
               
              };
         
              attributes.getAjaxCallListeners().add(listener);
        }

        @Override
        protected void respond(AjaxRequestTarget target)
        {
                
        }

}

am I missing something or this is a bug?

Thanks




--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/IAjaxCallListener-issues-in-AbstractDefaultAjaxBehavior-updateAjaxAttributes-tp4659055.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to