Re: How can I clear the value of an AutoCompleteTextField
target.appendJavascript(String.format(document.getElementById(%s).value = '', tagsTextfield.getMarkupId()));does not clear the text field. Any idea how to do this? Hbiloo On Thu, Feb 12, 2009 at 10:15 PM, Azzeddine Daddah waarhei...@gmail.comwrote: This is what I've till now. Clearing the text field does not work: private void addTagsPart(final Recipe recipe) { final WebMarkupContainer tagsContainer = new WebMarkupContainer(tagsContainer); final TagsAutoCompleteTextField tagsTextfield = new TagsAutoCompleteTextField(tags, new ModelTag()); add(tagsTextfield); tagsTextfield.add(new AjaxFormComponentUpdatingBehavior(onchange) { @Override protected void onUpdate(AjaxRequestTarget target) { String inputValue = tagsTextfield.getValue(); if (StringUtils.isNotBlank(inputValue)) { String[] splittedInputValues = StringUtils.split(inputValue, ,); for (String value : splittedInputValues) { recipe.addTag(new Tag(value)); } } } }); add(new IndicatingAjaxLinkString(addTagLink) { @Override public void onClick(AjaxRequestTarget target) { target.addComponent(tagsContainer); target.appendJavascript(String.format(document.getElementById(%s).value = '', tagsTextfield.getMarkupId())); target.appendJavascript(new Effect.Shake($(' + tagsContainer.getMarkupId() + '));); } }); tagsContainer.add(new ListViewTag(tags, new PropertyModelListTag(recipe, tags)) { @Override protected void populateItem(ListItemTag item) { Tag tag = item.getModelObject(); item.add(new Label(tag, tag.getName())); } }); tagsContainer.setOutputMarkupId(true); add(tagsContainer); } ... private class TagsAutoCompleteTextField extends AutoCompleteTextFieldTag { public TagsAutoCompleteTextField(String id, final IModelTag model) { super(id, model, new AbstractAutoCompleteTextRendererTag() { @Override protected String getTextValue(Tag tag) { return tag.getName(); } }); } @SuppressWarnings(unchecked) @Override protected IteratorTag getChoices(String input) { if (StringUtils.isBlank(input)) return Collections.EMPTY_LIST.iterator(); ListTag choices = new ArrayListTag(10); ListTag tags = RecipeService.getInstance().getAllPersistentTags(); for (Tag tag : tags) { if (tag.getName().toUpperCase().startsWith(input.toUpperCase())) { choices.add(tag); if (choices.size() == 10) break; } } return choices.iterator(); } } Regards, Hbiloo On Thu, Feb 12, 2009 at 5:00 PM, Martin Makundi martin.maku...@koodaripalvelut.com wrote: If you copy-paste your code here we can probably dig into it better ... ** Martin 2009/2/12 Azzeddine Daddah waarhei...@gmail.com: Thanks guys for the quick replay. Martin: What I want to do is to select a value from the auto complete text field, and when clicking the Add button, the selected value should be added to the tagsContainer (which is in fact a div that wraps the added values) and cleared from the text field. Luca: I've tried your suggestion but it didn't help. I've also tried to clear the text field using Javascript target.appendJavascript(String.format(document.getElementById('%s').value = '', auto.getOutputMarkupId())); but it also didn't work. Are there any other suggestions ways to implement this? Kind Regards Hbiloo On Thu, Feb 12, 2009 at 11:24 AM, Martin Makundi martin.maku...@koodaripalvelut.com wrote: Also depending on your situation, clearInput might be necessary? ** Martin 2009/2/12 Luca Provenzani eufor...@gmail.com: i think you can put the field of the model/bean of the form to empty and then call target.addComponet(tagsContainer); what kind of effect do you want? If you need to call javascript you can use target.appendJavaScript()... Luca 2009/2/12 Azzeddine Daddah waarhei...@gmail.com Hello everyone, Could someone please tell me how I can clear the selected value of an AutoCompleteTextField. I've an AutoCompleteTextField and a link which should clear the value of the text field after clicking it. I would also do some effects after clearing this value. Below my code: final AutoCompleteTextFieldString auto = new AutoCompleteTextFieldString(auto, new ModelString()) ... form.add(auto); form.add(new
Re: How can I clear the value of an AutoCompleteTextField
Also depending on your situation, clearInput might be necessary? ** Martin 2009/2/12 Luca Provenzani eufor...@gmail.com: i think you can put the field of the model/bean of the form to empty and then call target.addComponet(tagsContainer); what kind of effect do you want? If you need to call javascript you can use target.appendJavaScript()... Luca 2009/2/12 Azzeddine Daddah waarhei...@gmail.com Hello everyone, Could someone please tell me how I can clear the selected value of an AutoCompleteTextField. I've an AutoCompleteTextField and a link which should clear the value of the text field after clicking it. I would also do some effects after clearing this value. Below my code: final AutoCompleteTextFieldString auto = new AutoCompleteTextFieldString(auto, new ModelString()) ... form.add(auto); form.add(new IndicatingAjaxLinkString(addLink, new ModelString(Add)) { @Override public void onClick(AjaxRequestTarget target) { String inputValue = auto.getValue(); auto.clearInput(); // How to clear the auto's value and add some effects to the tagsContainer? target.addComponent(tagsContainer); } }); Kind Regards, Hbiloo - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: How can I clear the value of an AutoCompleteTextField
i think you can put the field of the model/bean of the form to empty and then call target.addComponet(tagsContainer); what kind of effect do you want? If you need to call javascript you can use target.appendJavaScript()... Luca 2009/2/12 Azzeddine Daddah waarhei...@gmail.com Hello everyone, Could someone please tell me how I can clear the selected value of an AutoCompleteTextField. I've an AutoCompleteTextField and a link which should clear the value of the text field after clicking it. I would also do some effects after clearing this value. Below my code: final AutoCompleteTextFieldString auto = new AutoCompleteTextFieldString(auto, new ModelString()) ... form.add(auto); form.add(new IndicatingAjaxLinkString(addLink, new ModelString(Add)) { @Override public void onClick(AjaxRequestTarget target) { String inputValue = auto.getValue(); auto.clearInput(); // How to clear the auto's value and add some effects to the tagsContainer? target.addComponent(tagsContainer); } }); Kind Regards, Hbiloo
Re: How can I clear the value of an AutoCompleteTextField
Thanks guys for the quick replay. Martin: What I want to do is to select a value from the auto complete text field, and when clicking the Add button, the selected value should be added to the tagsContainer (which is in fact a div that wraps the added values) and cleared from the text field. Luca: I've tried your suggestion but it didn't help. I've also tried to clear the text field using Javascript target.appendJavascript(String.format(document.getElementById('%s').value = '', auto.getOutputMarkupId())); but it also didn't work. Are there any other suggestions ways to implement this? Kind Regards Hbiloo On Thu, Feb 12, 2009 at 11:24 AM, Martin Makundi martin.maku...@koodaripalvelut.com wrote: Also depending on your situation, clearInput might be necessary? ** Martin 2009/2/12 Luca Provenzani eufor...@gmail.com: i think you can put the field of the model/bean of the form to empty and then call target.addComponet(tagsContainer); what kind of effect do you want? If you need to call javascript you can use target.appendJavaScript()... Luca 2009/2/12 Azzeddine Daddah waarhei...@gmail.com Hello everyone, Could someone please tell me how I can clear the selected value of an AutoCompleteTextField. I've an AutoCompleteTextField and a link which should clear the value of the text field after clicking it. I would also do some effects after clearing this value. Below my code: final AutoCompleteTextFieldString auto = new AutoCompleteTextFieldString(auto, new ModelString()) ... form.add(auto); form.add(new IndicatingAjaxLinkString(addLink, new ModelString(Add)) { @Override public void onClick(AjaxRequestTarget target) { String inputValue = auto.getValue(); auto.clearInput(); // How to clear the auto's value and add some effects to the tagsContainer? target.addComponent(tagsContainer); } }); Kind Regards, Hbiloo - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: How can I clear the value of an AutoCompleteTextField
If you copy-paste your code here we can probably dig into it better ... ** Martin 2009/2/12 Azzeddine Daddah waarhei...@gmail.com: Thanks guys for the quick replay. Martin: What I want to do is to select a value from the auto complete text field, and when clicking the Add button, the selected value should be added to the tagsContainer (which is in fact a div that wraps the added values) and cleared from the text field. Luca: I've tried your suggestion but it didn't help. I've also tried to clear the text field using Javascript target.appendJavascript(String.format(document.getElementById('%s').value = '', auto.getOutputMarkupId())); but it also didn't work. Are there any other suggestions ways to implement this? Kind Regards Hbiloo On Thu, Feb 12, 2009 at 11:24 AM, Martin Makundi martin.maku...@koodaripalvelut.com wrote: Also depending on your situation, clearInput might be necessary? ** Martin 2009/2/12 Luca Provenzani eufor...@gmail.com: i think you can put the field of the model/bean of the form to empty and then call target.addComponet(tagsContainer); what kind of effect do you want? If you need to call javascript you can use target.appendJavaScript()... Luca 2009/2/12 Azzeddine Daddah waarhei...@gmail.com Hello everyone, Could someone please tell me how I can clear the selected value of an AutoCompleteTextField. I've an AutoCompleteTextField and a link which should clear the value of the text field after clicking it. I would also do some effects after clearing this value. Below my code: final AutoCompleteTextFieldString auto = new AutoCompleteTextFieldString(auto, new ModelString()) ... form.add(auto); form.add(new IndicatingAjaxLinkString(addLink, new ModelString(Add)) { @Override public void onClick(AjaxRequestTarget target) { String inputValue = auto.getValue(); auto.clearInput(); // How to clear the auto's value and add some effects to the tagsContainer? target.addComponent(tagsContainer); } }); Kind Regards, Hbiloo - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: How can I clear the value of an AutoCompleteTextField
This is what I've till now. Clearing the text field does not work: private void addTagsPart(final Recipe recipe) { final WebMarkupContainer tagsContainer = new WebMarkupContainer(tagsContainer); final TagsAutoCompleteTextField tagsTextfield = new TagsAutoCompleteTextField(tags, new ModelTag()); add(tagsTextfield); tagsTextfield.add(new AjaxFormComponentUpdatingBehavior(onchange) { @Override protected void onUpdate(AjaxRequestTarget target) { String inputValue = tagsTextfield.getValue(); if (StringUtils.isNotBlank(inputValue)) { String[] splittedInputValues = StringUtils.split(inputValue, ,); for (String value : splittedInputValues) { recipe.addTag(new Tag(value)); } } } }); add(new IndicatingAjaxLinkString(addTagLink) { @Override public void onClick(AjaxRequestTarget target) { target.addComponent(tagsContainer); target.appendJavascript(String.format(document.getElementById(%s).value = '', tagsTextfield.getMarkupId())); target.appendJavascript(new Effect.Shake($(' + tagsContainer.getMarkupId() + '));); } }); tagsContainer.add(new ListViewTag(tags, new PropertyModelListTag(recipe, tags)) { @Override protected void populateItem(ListItemTag item) { Tag tag = item.getModelObject(); item.add(new Label(tag, tag.getName())); } }); tagsContainer.setOutputMarkupId(true); add(tagsContainer); } ... private class TagsAutoCompleteTextField extends AutoCompleteTextFieldTag { public TagsAutoCompleteTextField(String id, final IModelTag model) { super(id, model, new AbstractAutoCompleteTextRendererTag() { @Override protected String getTextValue(Tag tag) { return tag.getName(); } }); } @SuppressWarnings(unchecked) @Override protected IteratorTag getChoices(String input) { if (StringUtils.isBlank(input)) return Collections.EMPTY_LIST.iterator(); ListTag choices = new ArrayListTag(10); ListTag tags = RecipeService.getInstance().getAllPersistentTags(); for (Tag tag : tags) { if (tag.getName().toUpperCase().startsWith(input.toUpperCase())) { choices.add(tag); if (choices.size() == 10) break; } } return choices.iterator(); } } Regards, Hbiloo On Thu, Feb 12, 2009 at 5:00 PM, Martin Makundi martin.maku...@koodaripalvelut.com wrote: If you copy-paste your code here we can probably dig into it better ... ** Martin 2009/2/12 Azzeddine Daddah waarhei...@gmail.com: Thanks guys for the quick replay. Martin: What I want to do is to select a value from the auto complete text field, and when clicking the Add button, the selected value should be added to the tagsContainer (which is in fact a div that wraps the added values) and cleared from the text field. Luca: I've tried your suggestion but it didn't help. I've also tried to clear the text field using Javascript target.appendJavascript(String.format(document.getElementById('%s').value = '', auto.getOutputMarkupId())); but it also didn't work. Are there any other suggestions ways to implement this? Kind Regards Hbiloo On Thu, Feb 12, 2009 at 11:24 AM, Martin Makundi martin.maku...@koodaripalvelut.com wrote: Also depending on your situation, clearInput might be necessary? ** Martin 2009/2/12 Luca Provenzani eufor...@gmail.com: i think you can put the field of the model/bean of the form to empty and then call target.addComponet(tagsContainer); what kind of effect do you want? If you need to call javascript you can use target.appendJavaScript()... Luca 2009/2/12 Azzeddine Daddah waarhei...@gmail.com Hello everyone, Could someone please tell me how I can clear the selected value of an AutoCompleteTextField. I've an AutoCompleteTextField and a link which should clear the value of the text field after clicking it. I would also do some effects after clearing this value. Below my code: final AutoCompleteTextFieldString auto = new AutoCompleteTextFieldString(auto, new ModelString()) ... form.add(auto); form.add(new IndicatingAjaxLinkString(addLink, new ModelString(Add)) { @Override public void onClick(AjaxRequestTarget target) { String inputValue = auto.getValue(); auto.clearInput(); // How to clear the auto's value and add some effects to the tagsContainer?