You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Benjamin Heiskell <be...@gmail.com> on 2012/08/02 00:29:58 UTC

Repeating TextFields

Hi,

I have a List<String> that I want to represent with TextFields. I need
to be able to dynamically add and remove them via AJAX.

>From what I’ve read online (and experienced firsthand) ListViews do
not seem to be designed for this.

What is the best way to approach this problem?

Thanks!
Ben

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


Re: Repeating TextFields

Posted by Benjamin Heiskell <be...@gmail.com>.
Thank you, that's exactly the type of advice I was looking for!

On Thu, Aug 2, 2012 at 2:55 PM, Sven Meier <sv...@meiers.net> wrote:
> This is not possible with ListView.
>
> You have to switch to RefreshingView with a ReuseIfModelsEqualStrategy.
>
> Hope this helps
> Sven
>
>
> On 08/02/2012 08:45 PM, Benjamin Heiskell wrote:
>>
>> That makes the TextFields reflect their original model correctly, but
>> it also disposes of any modified values.
>>
>> For example:
>>    1. List starts with "1", "2", "3"
>>    2. Add two entries "4", "5"
>>    3. Modify "1" to "modified"
>>    4. Remove "2"
>>
>> What I would like to see is: "modified", "3", "4", "5"
>> What I end up seeing is: "1", "3", "", ""
>>
>> On Thu, Aug 2, 2012 at 1:44 PM, Sven Meier <sv...@meiers.net> wrote:
>>>
>>> After submit your TextFields still have their previous RAW_INPUT, call
>>> form#clearInput() so they render the value from the model.
>>>
>>> Sven
>>>
>>>
>>> On 08/02/2012 05:31 PM, Benjamin Heiskell wrote:
>>>>
>>>> Additions seem to work fine with setReuseItems(true), but I've been
>>>> having trouble with removals. My remove AjaxButton calls
>>>> listView.getList().remove(item.getIndex()), but that always removes
>>>> the last element. Am I making an incorrect assumption about how this
>>>> should work?
>>>>
>>>> The following is a simplified version of my FormComponentPanel that
>>>> replicates the problem. It's used the a CompoundPropertyModel with a
>>>> POJO containing the string list.
>>>>
>>>> public class TextFieldListView extends FormComponentPanel<List<String>>
>>>> {
>>>>
>>>>       private static final long serialVersionUID = 1L;
>>>>
>>>>       private final ListView<String> listView;
>>>>
>>>>       public TextFieldListView(final String id) {
>>>>           super(id);
>>>>
>>>>           setOutputMarkupId(true);
>>>>
>>>>           listView = new ListView<String>("list") {
>>>>               private static final long serialVersionUID = 1L;
>>>>
>>>>               @Override
>>>>               protected void populateItem(final ListItem<String> item) {
>>>>                   final TextField<String> textField = new
>>>> TextField<String>("item", item.getModel());
>>>>
>>>>                   item.add(textField);
>>>>                   item.add(new RemoveButton("remove", item));
>>>>               }
>>>>           };
>>>>
>>>>           listView.setReuseItems(true);
>>>>
>>>>           add(listView);
>>>>           add(new AddButton("add"));
>>>>       }
>>>>
>>>>       @Override
>>>>       public void onInitialize() {
>>>>           super.onInitialize();
>>>>           listView.setModel(getModel());
>>>>       }
>>>>
>>>>       @SuppressWarnings("unchecked")
>>>>       protected void convertInput() {
>>>>           this.setConvertedInput((List<String>)listView.getList());
>>>>       }
>>>>
>>>>       private class AddButton extends AjaxButton {
>>>>
>>>>           private static final long serialVersionUID = 1L;
>>>>
>>>>           public AddButton(final String id) {
>>>>               super(id);
>>>>               setDefaultFormProcessing(false);
>>>>           }
>>>>
>>>>           @Override
>>>>           protected void onSubmit(final AjaxRequestTarget target, final
>>>> Form<?> form) {
>>>>               listView.getModelObject().add("");
>>>>               target.add(TextFieldListView.this);
>>>>           }
>>>>
>>>>           @Override
>>>>           protected void onError(final AjaxRequestTarget target, final
>>>> Form<?> form) {
>>>>               throw new IllegalStateException("AJAX request threw an
>>>> error");
>>>>           }
>>>>       }
>>>>
>>>>       private class RemoveButton extends AjaxButton {
>>>>
>>>>           private static final long serialVersionUID = 1L;
>>>>
>>>>           private final ListItem<String> item;
>>>>
>>>>           public RemoveButton(final String id, final ListItem<String>
>>>> item)
>>>> {
>>>>               super(id);
>>>>               this.item = item;
>>>>               setDefaultFormProcessing(false);
>>>>           }
>>>>
>>>>           @Override
>>>>           protected void onSubmit(final AjaxRequestTarget target, final
>>>> Form<?> form) {
>>>>               listView.getList().remove(item.getIndex());
>>>>               target.add(TextFieldListView.this);
>>>>           }
>>>>
>>>>           @Override
>>>>           protected void onError(final AjaxRequestTarget target, final
>>>> Form<?> form) {
>>>>               throw new IllegalStateException("AJAX request threw an
>>>> error");
>>>>           }
>>>>       };
>>>> }
>>>>
>>>> Thanks!
>>>>
>>>> On Thu, Aug 2, 2012 at 10:13 AM, Andrea Del Bene <an...@gmail.com>
>>>> wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>> what kind of problem have you encountered with ListView?
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I have a List<String> that I want to represent with TextFields. I need
>>>>>> to be able to dynamically add and remove them via AJAX.
>>>>>>
>>>>>>    From what I’ve read online (and experienced firsthand) ListViews do
>>>>>> not seem to be designed for this.
>>>>>>
>>>>>> What is the best way to approach this problem?
>>>>>>
>>>>>> Thanks!
>>>>>> Ben
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>

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


Re: Repeating TextFields

Posted by Sven Meier <sv...@meiers.net>.
This is not possible with ListView.

You have to switch to RefreshingView with a ReuseIfModelsEqualStrategy.

Hope this helps
Sven

On 08/02/2012 08:45 PM, Benjamin Heiskell wrote:
> That makes the TextFields reflect their original model correctly, but
> it also disposes of any modified values.
>
> For example:
>    1. List starts with "1", "2", "3"
>    2. Add two entries "4", "5"
>    3. Modify "1" to "modified"
>    4. Remove "2"
>
> What I would like to see is: "modified", "3", "4", "5"
> What I end up seeing is: "1", "3", "", ""
>
> On Thu, Aug 2, 2012 at 1:44 PM, Sven Meier <sv...@meiers.net> wrote:
>> After submit your TextFields still have their previous RAW_INPUT, call
>> form#clearInput() so they render the value from the model.
>>
>> Sven
>>
>>
>> On 08/02/2012 05:31 PM, Benjamin Heiskell wrote:
>>> Additions seem to work fine with setReuseItems(true), but I've been
>>> having trouble with removals. My remove AjaxButton calls
>>> listView.getList().remove(item.getIndex()), but that always removes
>>> the last element. Am I making an incorrect assumption about how this
>>> should work?
>>>
>>> The following is a simplified version of my FormComponentPanel that
>>> replicates the problem. It's used the a CompoundPropertyModel with a
>>> POJO containing the string list.
>>>
>>> public class TextFieldListView extends FormComponentPanel<List<String>> {
>>>
>>>       private static final long serialVersionUID = 1L;
>>>
>>>       private final ListView<String> listView;
>>>
>>>       public TextFieldListView(final String id) {
>>>           super(id);
>>>
>>>           setOutputMarkupId(true);
>>>
>>>           listView = new ListView<String>("list") {
>>>               private static final long serialVersionUID = 1L;
>>>
>>>               @Override
>>>               protected void populateItem(final ListItem<String> item) {
>>>                   final TextField<String> textField = new
>>> TextField<String>("item", item.getModel());
>>>
>>>                   item.add(textField);
>>>                   item.add(new RemoveButton("remove", item));
>>>               }
>>>           };
>>>
>>>           listView.setReuseItems(true);
>>>
>>>           add(listView);
>>>           add(new AddButton("add"));
>>>       }
>>>
>>>       @Override
>>>       public void onInitialize() {
>>>           super.onInitialize();
>>>           listView.setModel(getModel());
>>>       }
>>>
>>>       @SuppressWarnings("unchecked")
>>>       protected void convertInput() {
>>>           this.setConvertedInput((List<String>)listView.getList());
>>>       }
>>>
>>>       private class AddButton extends AjaxButton {
>>>
>>>           private static final long serialVersionUID = 1L;
>>>
>>>           public AddButton(final String id) {
>>>               super(id);
>>>               setDefaultFormProcessing(false);
>>>           }
>>>
>>>           @Override
>>>           protected void onSubmit(final AjaxRequestTarget target, final
>>> Form<?> form) {
>>>               listView.getModelObject().add("");
>>>               target.add(TextFieldListView.this);
>>>           }
>>>
>>>           @Override
>>>           protected void onError(final AjaxRequestTarget target, final
>>> Form<?> form) {
>>>               throw new IllegalStateException("AJAX request threw an
>>> error");
>>>           }
>>>       }
>>>
>>>       private class RemoveButton extends AjaxButton {
>>>
>>>           private static final long serialVersionUID = 1L;
>>>
>>>           private final ListItem<String> item;
>>>
>>>           public RemoveButton(final String id, final ListItem<String> item)
>>> {
>>>               super(id);
>>>               this.item = item;
>>>               setDefaultFormProcessing(false);
>>>           }
>>>
>>>           @Override
>>>           protected void onSubmit(final AjaxRequestTarget target, final
>>> Form<?> form) {
>>>               listView.getList().remove(item.getIndex());
>>>               target.add(TextFieldListView.this);
>>>           }
>>>
>>>           @Override
>>>           protected void onError(final AjaxRequestTarget target, final
>>> Form<?> form) {
>>>               throw new IllegalStateException("AJAX request threw an
>>> error");
>>>           }
>>>       };
>>> }
>>>
>>> Thanks!
>>>
>>> On Thu, Aug 2, 2012 at 10:13 AM, Andrea Del Bene <an...@gmail.com>
>>> wrote:
>>>> Hi,
>>>>
>>>> what kind of problem have you encountered with ListView?
>>>>> Hi,
>>>>>
>>>>> I have a List<String> that I want to represent with TextFields. I need
>>>>> to be able to dynamically add and remove them via AJAX.
>>>>>
>>>>>    From what I’ve read online (and experienced firsthand) ListViews do
>>>>> not seem to be designed for this.
>>>>>
>>>>> What is the best way to approach this problem?
>>>>>
>>>>> Thanks!
>>>>> Ben
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


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


Re: Repeating TextFields

Posted by Benjamin Heiskell <be...@gmail.com>.
That makes the TextFields reflect their original model correctly, but
it also disposes of any modified values.

For example:
  1. List starts with "1", "2", "3"
  2. Add two entries "4", "5"
  3. Modify "1" to "modified"
  4. Remove "2"

What I would like to see is: "modified", "3", "4", "5"
What I end up seeing is: "1", "3", "", ""

On Thu, Aug 2, 2012 at 1:44 PM, Sven Meier <sv...@meiers.net> wrote:
> After submit your TextFields still have their previous RAW_INPUT, call
> form#clearInput() so they render the value from the model.
>
> Sven
>
>
> On 08/02/2012 05:31 PM, Benjamin Heiskell wrote:
>>
>> Additions seem to work fine with setReuseItems(true), but I've been
>> having trouble with removals. My remove AjaxButton calls
>> listView.getList().remove(item.getIndex()), but that always removes
>> the last element. Am I making an incorrect assumption about how this
>> should work?
>>
>> The following is a simplified version of my FormComponentPanel that
>> replicates the problem. It's used the a CompoundPropertyModel with a
>> POJO containing the string list.
>>
>> public class TextFieldListView extends FormComponentPanel<List<String>> {
>>
>>      private static final long serialVersionUID = 1L;
>>
>>      private final ListView<String> listView;
>>
>>      public TextFieldListView(final String id) {
>>          super(id);
>>
>>          setOutputMarkupId(true);
>>
>>          listView = new ListView<String>("list") {
>>              private static final long serialVersionUID = 1L;
>>
>>              @Override
>>              protected void populateItem(final ListItem<String> item) {
>>                  final TextField<String> textField = new
>> TextField<String>("item", item.getModel());
>>
>>                  item.add(textField);
>>                  item.add(new RemoveButton("remove", item));
>>              }
>>          };
>>
>>          listView.setReuseItems(true);
>>
>>          add(listView);
>>          add(new AddButton("add"));
>>      }
>>
>>      @Override
>>      public void onInitialize() {
>>          super.onInitialize();
>>          listView.setModel(getModel());
>>      }
>>
>>      @SuppressWarnings("unchecked")
>>      protected void convertInput() {
>>          this.setConvertedInput((List<String>)listView.getList());
>>      }
>>
>>      private class AddButton extends AjaxButton {
>>
>>          private static final long serialVersionUID = 1L;
>>
>>          public AddButton(final String id) {
>>              super(id);
>>              setDefaultFormProcessing(false);
>>          }
>>
>>          @Override
>>          protected void onSubmit(final AjaxRequestTarget target, final
>> Form<?> form) {
>>              listView.getModelObject().add("");
>>              target.add(TextFieldListView.this);
>>          }
>>
>>          @Override
>>          protected void onError(final AjaxRequestTarget target, final
>> Form<?> form) {
>>              throw new IllegalStateException("AJAX request threw an
>> error");
>>          }
>>      }
>>
>>      private class RemoveButton extends AjaxButton {
>>
>>          private static final long serialVersionUID = 1L;
>>
>>          private final ListItem<String> item;
>>
>>          public RemoveButton(final String id, final ListItem<String> item)
>> {
>>              super(id);
>>              this.item = item;
>>              setDefaultFormProcessing(false);
>>          }
>>
>>          @Override
>>          protected void onSubmit(final AjaxRequestTarget target, final
>> Form<?> form) {
>>              listView.getList().remove(item.getIndex());
>>              target.add(TextFieldListView.this);
>>          }
>>
>>          @Override
>>          protected void onError(final AjaxRequestTarget target, final
>> Form<?> form) {
>>              throw new IllegalStateException("AJAX request threw an
>> error");
>>          }
>>      };
>> }
>>
>> Thanks!
>>
>> On Thu, Aug 2, 2012 at 10:13 AM, Andrea Del Bene <an...@gmail.com>
>> wrote:
>>>
>>> Hi,
>>>
>>> what kind of problem have you encountered with ListView?
>>>>
>>>> Hi,
>>>>
>>>> I have a List<String> that I want to represent with TextFields. I need
>>>> to be able to dynamically add and remove them via AJAX.
>>>>
>>>>   From what I’ve read online (and experienced firsthand) ListViews do
>>>> not seem to be designed for this.
>>>>
>>>> What is the best way to approach this problem?
>>>>
>>>> Thanks!
>>>> Ben
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>

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


Re: Repeating TextFields

Posted by Sven Meier <sv...@meiers.net>.
After submit your TextFields still have their previous RAW_INPUT, call 
form#clearInput() so they render the value from the model.

Sven

On 08/02/2012 05:31 PM, Benjamin Heiskell wrote:
> Additions seem to work fine with setReuseItems(true), but I've been
> having trouble with removals. My remove AjaxButton calls
> listView.getList().remove(item.getIndex()), but that always removes
> the last element. Am I making an incorrect assumption about how this
> should work?
>
> The following is a simplified version of my FormComponentPanel that
> replicates the problem. It's used the a CompoundPropertyModel with a
> POJO containing the string list.
>
> public class TextFieldListView extends FormComponentPanel<List<String>> {
>
>      private static final long serialVersionUID = 1L;
>
>      private final ListView<String> listView;
>
>      public TextFieldListView(final String id) {
>          super(id);
>
>          setOutputMarkupId(true);
>
>          listView = new ListView<String>("list") {
>              private static final long serialVersionUID = 1L;
>
>              @Override
>              protected void populateItem(final ListItem<String> item) {
>                  final TextField<String> textField = new
> TextField<String>("item", item.getModel());
>
>                  item.add(textField);
>                  item.add(new RemoveButton("remove", item));
>              }
>          };
>
>          listView.setReuseItems(true);
>
>          add(listView);
>          add(new AddButton("add"));
>      }
>
>      @Override
>      public void onInitialize() {
>          super.onInitialize();
>          listView.setModel(getModel());
>      }
>
>      @SuppressWarnings("unchecked")
>      protected void convertInput() {
>          this.setConvertedInput((List<String>)listView.getList());
>      }
>
>      private class AddButton extends AjaxButton {
>
>          private static final long serialVersionUID = 1L;
>
>          public AddButton(final String id) {
>              super(id);
>              setDefaultFormProcessing(false);
>          }
>
>          @Override
>          protected void onSubmit(final AjaxRequestTarget target, final
> Form<?> form) {
>              listView.getModelObject().add("");
>              target.add(TextFieldListView.this);
>          }
>
>          @Override
>          protected void onError(final AjaxRequestTarget target, final
> Form<?> form) {
>              throw new IllegalStateException("AJAX request threw an error");
>          }
>      }
>
>      private class RemoveButton extends AjaxButton {
>
>          private static final long serialVersionUID = 1L;
>
>          private final ListItem<String> item;
>
>          public RemoveButton(final String id, final ListItem<String> item) {
>              super(id);
>              this.item = item;
>              setDefaultFormProcessing(false);
>          }
>
>          @Override
>          protected void onSubmit(final AjaxRequestTarget target, final
> Form<?> form) {
>              listView.getList().remove(item.getIndex());
>              target.add(TextFieldListView.this);
>          }
>
>          @Override
>          protected void onError(final AjaxRequestTarget target, final
> Form<?> form) {
>              throw new IllegalStateException("AJAX request threw an error");
>          }
>      };
> }
>
> Thanks!
>
> On Thu, Aug 2, 2012 at 10:13 AM, Andrea Del Bene <an...@gmail.com> wrote:
>> Hi,
>>
>> what kind of problem have you encountered with ListView?
>>> Hi,
>>>
>>> I have a List<String> that I want to represent with TextFields. I need
>>> to be able to dynamically add and remove them via AJAX.
>>>
>>>   From what I’ve read online (and experienced firsthand) ListViews do
>>> not seem to be designed for this.
>>>
>>> What is the best way to approach this problem?
>>>
>>> Thanks!
>>> Ben
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


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


Re: Repeating TextFields

Posted by Benjamin Heiskell <be...@gmail.com>.
Additions seem to work fine with setReuseItems(true), but I've been
having trouble with removals. My remove AjaxButton calls
listView.getList().remove(item.getIndex()), but that always removes
the last element. Am I making an incorrect assumption about how this
should work?

The following is a simplified version of my FormComponentPanel that
replicates the problem. It's used the a CompoundPropertyModel with a
POJO containing the string list.

public class TextFieldListView extends FormComponentPanel<List<String>> {

    private static final long serialVersionUID = 1L;

    private final ListView<String> listView;

    public TextFieldListView(final String id) {
        super(id);

        setOutputMarkupId(true);

        listView = new ListView<String>("list") {
            private static final long serialVersionUID = 1L;

            @Override
            protected void populateItem(final ListItem<String> item) {
                final TextField<String> textField = new
TextField<String>("item", item.getModel());

                item.add(textField);
                item.add(new RemoveButton("remove", item));
            }
        };

        listView.setReuseItems(true);

        add(listView);
        add(new AddButton("add"));
    }

    @Override
    public void onInitialize() {
        super.onInitialize();
        listView.setModel(getModel());
    }

    @SuppressWarnings("unchecked")
    protected void convertInput() {
        this.setConvertedInput((List<String>)listView.getList());
    }

    private class AddButton extends AjaxButton {

        private static final long serialVersionUID = 1L;

        public AddButton(final String id) {
            super(id);
            setDefaultFormProcessing(false);
        }

        @Override
        protected void onSubmit(final AjaxRequestTarget target, final
Form<?> form) {
            listView.getModelObject().add("");
            target.add(TextFieldListView.this);
        }

        @Override
        protected void onError(final AjaxRequestTarget target, final
Form<?> form) {
            throw new IllegalStateException("AJAX request threw an error");
        }
    }

    private class RemoveButton extends AjaxButton {

        private static final long serialVersionUID = 1L;

        private final ListItem<String> item;

        public RemoveButton(final String id, final ListItem<String> item) {
            super(id);
            this.item = item;
            setDefaultFormProcessing(false);
        }

        @Override
        protected void onSubmit(final AjaxRequestTarget target, final
Form<?> form) {
            listView.getList().remove(item.getIndex());
            target.add(TextFieldListView.this);
        }

        @Override
        protected void onError(final AjaxRequestTarget target, final
Form<?> form) {
            throw new IllegalStateException("AJAX request threw an error");
        }
    };
}

Thanks!

On Thu, Aug 2, 2012 at 10:13 AM, Andrea Del Bene <an...@gmail.com> wrote:
> Hi,
>
> what kind of problem have you encountered with ListView?
>>
>> Hi,
>>
>> I have a List<String> that I want to represent with TextFields. I need
>> to be able to dynamically add and remove them via AJAX.
>>
>>  From what I’ve read online (and experienced firsthand) ListViews do
>> not seem to be designed for this.
>>
>> What is the best way to approach this problem?
>>
>> Thanks!
>> Ben
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>

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


Re: Repeating TextFields

Posted by Andrea Del Bene <an...@gmail.com>.
Hi,

what kind of problem have you encountered with ListView?
> Hi,
>
> I have a List<String> that I want to represent with TextFields. I need
> to be able to dynamically add and remove them via AJAX.
>
>  From what I’ve read online (and experienced firsthand) ListViews do
> not seem to be designed for this.
>
> What is the best way to approach this problem?
>
> Thanks!
> Ben
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


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