I had an ajaxbutton to add selected items from a multiple choice control to
another multiple choice control.  This worked spendidly with me getting the
selected via the getInput() method.  Well, along comes time for me to write
and add a validator to the form, and suddenly the event does not arrive. 
Pull the validator back out and everything works.  So clearly the validator
is in the way, but it shouldn't be...it's not validation time yet!

Question 1: Why would a form validator interfere with an ajaxbutton's event? 
It was NOT a submit button.

Then a co-worker suggested I try to use AjaxLink instead of button, but tie
it to a button.  This allows the event in (Hooray!) but now getInput()
returns null.  As if AjaxLink doesn't bring any screen controls other than
itself.

Question 2: Why is AjaxLink making getInput() null?  If there is some other
mechanism to get form data, what is that mechanism?  

The AjaxLink code looks like:

                add(new AjaxLink("addSelected") {
                        private static final long serialVersionUID = 1L;
                        @Override
                        public void onClick(AjaxRequestTarget target) {
                                onAddSelected(target);
                        }
                });

        private void onAddSelected(AjaxRequestTarget target) {
                if(listUsers.getInput()!=null) {  //listUsers is null
                        List<String> newChoices = (List<String>) 
listUsers.getChoices();
                        List<String> selChoices = new ArrayList<String>();
                        for(String index: listUsers.getInputAsArray()) 
                                
selChoices.add(newChoices.get(Integer.parseInt(index)));
                        mergeUniquelyIntoRecipients(recipients, selChoices);
                }
                listUsers.setModelObject(new ArrayList<String>());
                target.addComponent(listUsers);
                target.addComponent(selected);
        }




--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Ajax-and-validators-tp4657570.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

Reply via email to