Oops, I did not saw you was using an AjaxLink... You have to use an
AjaxButton instead.

Sebastien.

On Tue, May 1, 2012 at 5:51 PM, cmagnollay <cmagnol...@gmail.com> wrote:

> Well, that is not the case unfortunately. Here is my code as stripped down
> as
> I could get it, to still supply information about what I am doing. If you
> have any questions I would be happy to answer.
>
>
> public class MyPage extends WebPage
> {
>        private TextField quantityField;
>
>        private Button doneButton = new Button("doneButton");
>
>        /**List of version numbers*/
>        private static final List versions = Arrays.asList(new Integer[]{6,
> 5, 4});
>        /**Selected version of item to search for*/
>        private int version = 6;
>
>        private AutoCompleteTextField itemField;
>        /**ListView of items currently selected by user*/
>        private ListView<Map.Entry&lt;Item, Integer>> itemList;
>        /**Container for list view so AJAX calls can reference it*/
>        private WebMarkupContainer itemListContainer;
>
>        /**Link prompting AJAX response to display the item that was added*/
>        private AjaxLink addItemLink;
>
>        private FeedbackPanel feedback = new FeedbackPanel("feedback");
>
>        private Map<Item, Integer> itemMap = new HashMap<Item, Integer>();
>
>        public MyPage(final PageParameters params)
>        {
>                super(params);
>
>                feedback.setOutputMarkupId(true);
>
>                Form<?> customerForm = new Form("customerForm"){
>
>                        private static final long serialVersionUID = 1L;
>
>                         protected void onSubmit()
>                        {
>                                //do stuff
>                        }
>                };
>                customerForm.setOutputMarkupId(true);
>
>                final DropDownChoice versionChoice = new
> DropDownChoice("versionChoice",
> new PropertyModel(this, "version"), versions);
>
>                itemField = new
> DefaultCssAutoCompleteTextField("itemField", new Model()){
>
>                        private static final long serialVersionUID = 1L;
>
>                        @Override
>                         protected Iterator getChoices(String text)
>                        {
>                                List items = new LinkedList();
>
>                                //fill items and do some string
> manipulation and database access
>
>                                Collections.sort(items);
>
>                                return items.iterator();
>                        }
>
>                };
>                itemField.setOutputMarkupId(true);
>
>                quantityField = new TextField("quantityField", new Model());
>                quantityField.setOutputMarkupId(true);
>
>                addItemLink = new AjaxLink("addItemLink", new Model("Add
> Item")){
>
>                        private static final long serialVersionUID = 1L;
>
>                        @Override
>                        public void onClick(AjaxRequestTarget target)
>                        {
>                                String selectedItem = itemField.getValue();
>                                String[] fields = selectedItem.split(" | ");
>
>                                info("Value of input: " + selectedItem);
>
>                                target.add(feedback);
>                        }
>
>                };
>                 addItemLink.setOutputMarkupId(true);
>
>                customerForm.add(itemField);
>                customerForm.add(versionChoice);
>                customerForm.add(quantityField);
>                customerForm.add(addItemLink);
>                customerForm.add(doneButton);
>
>                IModel<List&lt;Map.Entry&lt;Item, Integer>>> lvModel = new
> LoadableDetachableModel<List&lt;Map.Entry&lt;Item, Integer>>>(){
>                         private static final long serialVersionUID = 1L;
>
>                        @Override
>                         protected List<Entry&lt;Item, Integer>> load()
>                        {
>                                return new
> ArrayList<Map.Entry&lt;Item,Integer>>(itemMap.entrySet());
>                        }
>
>                };
>
>                itemList = new ListView<Map.Entry&lt;Item,
> Integer>>("itemList", lvModel){
>                         private static final long serialVersionUID = 1L;
>
>                        @Override
>                         protected void
> populateItem(ListItem<Map.Entry&lt;Item, Integer>> item)
>                        {
>                                Item i = item.getModelObject().getKey();
>                                int quantity =
> item.getModelObject().getValue();
>
>                                item.add(new Label(quantity + "x " +
> getItemText(i, true)));
>                        }
>                };
>
>                itemListContainer = new
> WebMarkupContainer("itemListContainer");
>                itemListContainer.add(itemList);
>                itemListContainer.setOutputMarkupId(true);
>
>                add(new NavigationBar("nav"));
>                add(feedback);
>                add(customerForm);
>                add(itemListContainer);
>        }
> }
>
>
>
> Thanks for your help.
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/AutoCompleteField-returning-null-tp4600764p4601022.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