Ajax link doesn't call event

View: New views
8 Messages — Rating Filter:   Alert me  

Ajax link doesn't call event

by ezegb :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi, the situation is as follows:

I have a form embedded in an abstract panel. The form has an autocompletetextfield and an AjaxSubmitLink which acts on the data in the textfield. The panel, in turn, extends several other panels which are in the end the ones that get instantiated.

The very code for the AjaxSubmitLink is used elsewhere and works fine. Now, the issue is that when called on this panel, it won't call its onSubmit event. It won't call any other onSubmit event, either. I am certain the code is placed in a class extending Form on the Java side, and it's certainly enclosed by <form> in the markup. I'm at a total loss with this situation, since it does work in the very same page (the final page has two forms, the first one works perfectly, the second -this one- does not).

Any help will be most appreciated.

Thanks,

Ezequiel


Re: [Follow up] Ajax link doesn't call event

by ezegb :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I ended up commenting loads of code and it turns out my Ajax link will quit responding if it has something else after itself in the form. I got rid of all the textfields that followed, and I got it to work. The troublesome component is actually the ajax link, plus a textfield to input data, plus a listview displaying that data (the ajax link updates the object and the listview)

Thanks,

Ezequiel

ezegb wrote:
Hi, the situation is as follows:

I have a form embedded in an abstract panel. The form has an autocompletetextfield and an AjaxSubmitLink which acts on the data in the textfield. The panel, in turn, extends several other panels which are in the end the ones that get instantiated.

The very code for the AjaxSubmitLink is used elsewhere and works fine. Now, the issue is that when called on this panel, it won't call its onSubmit event. It won't call any other onSubmit event, either. I am certain the code is placed in a class extending Form on the Java side, and it's certainly enclosed by <form> in the markup. I'm at a total loss with this situation, since it does work in the very same page (the final page has two forms, the first one works perfectly, the second -this one- does not).

Any help will be most appreciated.

Thanks,

Ezequiel

Re: [Follow up] Ajax link doesn't call event

by Timo Rantalaiho :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, 01 Jul 2008, ezegb wrote:
> I ended up commenting loads of code and it turns out my Ajax link will quit
> responding if it has something else after itself in the form. I got rid of
> all the textfields that followed, and I got it to work. The troublesome
> component is actually the ajax link, plus a textfield to input data, plus a
> listview displaying that data (the ajax link updates the object and the
> listview)

If you can provide a quickstart containing only the few
necessary parts, others can try checking it it's a bug or
if you can fix something in your code.

Best wishes,
Timo

--
Timo Rantalaiho          
Reaktor Innovations Oy    <URL: http://www.ri.fi/ >

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: [Follow up] Ajax link doesn't call event

by ezegb :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi, thanks for your reply. As I said, the troublesome component seems to be a container which is composed of the following:

                                ListView author = new CompoundListView("author")
                                {
                                        private static final long serialVersionUID = 1L;

                                        @Override
                                        protected void populateItem(final ListItem item)
                                        {
                                                item.add(new Label("name"));

                                                // Ajax link to delete the current row
                                                AjaxSubmitLink deleteRow = new AjaxSubmitLink("deleteRow")
                                                {

                                                        private static final long serialVersionUID = 1L;

                                                        @SuppressWarnings("unchecked")
                                                        @Override
                                                        protected void onSubmit(AjaxRequestTarget target, Form form)
                                                        {
                                                                ProjectProduct projectProduct = (ProjectProduct) this.getModelObject();
                                                                projectProduct.getAuthor().remove(item.getIndex());
                                                                target.addComponent(authorContainer);
                                                        }
                                                };
                                                item.add(deleteRow);
                                        }
                                };
                                authorContainer.add(author);

                                final AutoCompleteTextField personName = new AutoCompleteTextField("personName", new Model())
                                {
                                        private static final long serialVersionUID = 1L;

                                        @SuppressWarnings("unchecked")
                                        @Override
                                        protected Iterator getChoices(String input)
                                        {
                                                List<String> results = new ArrayList<String>();
                                                if (input.length() < MINAUTCOMPLETEINPUTLENGHT) {
                                                        results.add(getLocalizer().getString("search.parameter.too.short", this));
                                                       
                                                }
                                                else {
                                                        Criteria criteria = new Criteria();
                                                        criteria.addFilter("lastName", CriteriaOperators.BEGINSWITH, input);


                                                        for(PersonInfo p : uService.getPersonInfoByCriteria(criteria, defaultPaginator)) {
                                                                //only filter professors
                                                                        results.add(p.getName() + " - " + "D.N.I.:" + p.getDni());
                                                        }
                                                }
                                                if(results.size() == MAXAUTOCOMPLETEROWS) {
                                                        results.add(getLocalizer().getString("too.many.results", this));
                                                }
                                                return results.iterator();
                                        }
                                };
                                authorContainer.add(personName);

                                // Ajax link to add a row
                                AjaxSubmitLink addAuthor = new AjaxSubmitLink("addAuthor")
                                {
                                        private static final long serialVersionUID = 1L;

                                        @Override
                                        protected void onSubmit(AjaxRequestTarget target,
                                                        Form form)
                                        {
                                                ProjectProduct projectProduct = (ProjectProduct) form.getModelObject();
                                                String name = (String)personName.getConvertedInput();
                                                if(name == null)
                                                {
                                                        //Error

                                                }
                                                else
                                                {
                                                        String dni = EditProjectForm.extractDniFromUserString(name);
                                                        PersonInfo aPerson = uService.getPersonInfobyDNI(dni);
                                                        if(!projectProduct.getAuthor().contains(aPerson) && aPerson != null)
                                                        {
                                                                projectProduct.addAuthor(aPerson);
                                                                //target.addComponent(authorContainer);
                                                        }
                                                        else if(aPerson == null)
                                                        {
                                                                //Error por inexistente
                                                        }
                                                        else
                                                        {
                                                                //Error por repetido
                                                        }
                                                }
                                                target.addComponent(authorContainer);
                                        }
                                };
                                authorContainer.add(addAuthor);

This is in turn inside a class extending Form, and the container is declared as follows:
                                final WebMarkupContainer authorContainer = new WebMarkupContainer("authorContainer");
                                authorContainer.setOutputMarkupId(true);
                                add(authorContainer);

I'd like to stress that this same code is working elsewhere, though there's no lonely textfields beneath in that form, but there are other similar containers.

Author is a lisview displaying all authors, the autocompletetextfield is used to input a new author, and the button is supposed to add the author to the list.

Thanks,

Ezequiel


Timo Rantalaiho wrote:
If you can provide a quickstart containing only the few
necessary parts, others can try checking it it's a bug or
if you can fix something in your code.

Best wishes,
Timo

--
Timo Rantalaiho          
Reaktor Innovations Oy    <URL: http://www.ri.fi/ >

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org

Re: [Follow up] Ajax link doesn't call event

by Timo Rantalaiho :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, 02 Jul 2008, ezegb wrote:
> I'd like to stress that this same code is working elsewhere, though there's
> no lonely textfields beneath in that form, but there are other similar
> containers.

Sorry but it's very hard to get a grasp of the code from the
email -- at least I couldn't see anything straight away. It
would be easier for me and others to look at your code in a
working quickstart project, created e.g. with this

  http://wicket.apache.org/quickstart.html

Off-topic: Hmm, D.N.I.! Are you working in some Latin American
country by any chance?-)

Best wishes,
Timo

--
Timo Rantalaiho          
Reaktor Innovations Oy    <URL: http://www.ri.fi/ >

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: [Follow up] Ajax link doesn't call event

by ezegb :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Timo, yes I'm from Argentina, DNI's the Documento Nacional de Identidad :p

Regarding the issue, we did nail it down todays, turns out Ajax was rejecting the request because of empty required textfields elsewhere in the form. Now, the following issue is we couldn't quite catch the validation so as to have the Ajax onSubmit ignore it. I did attempt a naive override of onError as well as calling this method whose name I cannot find right now which receives a boolean and if false overrides validation and such and proceeds directly to onSubmit. Any ideas are appreciated

Thanks,

Ezequiel

Timo Rantalaiho wrote:
On Wed, 02 Jul 2008, ezegb wrote:

Off-topic: Hmm, D.N.I.! Are you working in some Latin American
country by any chance?-)

Best wishes,
Timo

--
Timo Rantalaiho          
Reaktor Innovations Oy    <URL: http://www.ri.fi/ >

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org

Re: [Follow up] Ajax link doesn't call event

by Timo Rantalaiho :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, 02 Jul 2008, ezegb wrote:
> Hi Timo, yes I'm from Argentina, DNI's the Documento Nacional de Identidad :p

I thought it rang a bell :)

> Regarding the issue, we did nail it down todays, turns out Ajax was
> rejecting the request because of empty required textfields elsewhere in the
> form. Now, the following issue is we couldn't quite catch the validation so
> as to have the Ajax onSubmit ignore it. I did attempt a naive override of
> onError as well as calling this method whose name I cannot find right now
> which receives a boolean and if false overrides validation and such and
> proceeds directly to onSubmit. Any ideas are appreciated

It's always a good idea to override onError because of this.
I think that with a good onSubmit / onError collaboration
you can get a good solution.

Suerte,
Timo

--
Timo Rantalaiho          
Reaktor Innovations Oy    <URL: http://www.ri.fi/ >

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: [Follow up] Ajax link doesn't call event

by only4you :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Lack of "super" section cause that kind of a problem. Look at example:


AjaxEditableLabel label = new AjaxEditableLabel(componentId, new PropertyModel(dtoUser, "loginName")){
                                      @Override
                                      protected void onEdit(AjaxRequestTarget target) {
                                        super.onEdit(target);
                                        log.debug("ListCopies.ListCopies().loginNameColumn.onEdit: "+dtoUser.getId()+" "+dtoUser.getLoginName()+" "+dtoUser.getFirstName()+" "+dtoUser.getLastName());
                                      }
                                      @Override
                                      protected void onError(AjaxRequestTarget target) {
                                        super.onError(target);
                                        target.addComponent(getFeedbackPanel());
                                        log.error("ListCopies.ListCopies().loginNameColumn.onError: "+dtoUser.getId()+" "+dtoUser.getLoginName()+" "+dtoUser.getFirstName()+" "+dtoUser.getLastName());
                                      }
                                      @Override
                                      public void onSubmit(AjaxRequestTarget target){
                                                super.onSubmit(target);
                                                log.debug("ListCopies.ListCopies().loginNameColumn.onSubmit: "+dtoUser.getId()+" "+dtoUser.getLoginName());
                                                ((LibraryApplication) getApplication()).getManageUser().saveObject(dtoUser);
                                      }
                                };




ezegb wrote:
                                                        @SuppressWarnings("unchecked")
                                                        @Override
                                                        protected void onSubmit(AjaxRequestTarget target, Form form)
                                                        {
                                                                ProjectProduct projectProduct = (ProjectProduct) this.getModelObject();
                                                                projectProduct.getAuthor().remove(item.getIndex());
                                                                target.addComponent(authorContainer);
                                                        }
                                               
LightInTheBox - Buy quality products at wholesale price!