Re: Repeating TextFields

2012-08-06 Thread vineet semwal
actually with quickview you can add/remove any number of items but i
might have overread/misunderstood what martin is saying..

On Thu, Aug 2, 2012 at 12:37 PM, Martin Grigorov mgrigo...@apache.org wrote:
 On Thu, Aug 2, 2012 at 3:25 AM, Benjamin Heiskell
 ben.heisk...@gmail.com wrote:
 Hi,

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

 For dynamic add/remove of a single item see :
 https://github.com/vineetsemwal/quickview/wiki


 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-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




 --
 Martin Grigorov
 jWeekend
 Training, Consulting, Development
 http://jWeekend.com

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




-- 
regards,

Vineet Semwal

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



Re: Repeating TextFields

2012-08-06 Thread Martin Grigorov
On Mon, Aug 6, 2012 at 12:52 PM, vineet semwal vineetsemwa...@gmail.com wrote:
 actually with quickview you can add/remove any number of items but i
 might have overread/misunderstood what martin is saying..

Correct!
I meant to add/remove just items without the need to repaint the
parent of the repeater.


 On Thu, Aug 2, 2012 at 12:37 PM, Martin Grigorov mgrigo...@apache.org wrote:
 On Thu, Aug 2, 2012 at 3:25 AM, Benjamin Heiskell
 ben.heisk...@gmail.com wrote:
 Hi,

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

 For dynamic add/remove of a single item see :
 https://github.com/vineetsemwal/quickview/wiki


 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-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




 --
 Martin Grigorov
 jWeekend
 Training, Consulting, Development
 http://jWeekend.com

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




 --
 regards,

 Vineet Semwal

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




-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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



Re: Repeating TextFields

2012-08-06 Thread vineet semwal
quickview *can* add/remove any number of items without the need to
repaint the parent of repeater,check the examples in the quickview ;)
,AjaxItemsNavigator and other new onscroll behaviors which i have
added recently would not have been possible if quickview was not
capable of that,they work like click/onscroll to see new rows added
like what you see in social networking applications...

On Mon, Aug 6, 2012 at 3:34 PM, Martin Grigorov mgrigo...@apache.org wrote:
 On Mon, Aug 6, 2012 at 12:52 PM, vineet semwal vineetsemwa...@gmail.com 
 wrote:
 actually with quickview you can add/remove any number of items but i
 might have overread/misunderstood what martin is saying..

 Correct!
 I meant to add/remove just items without the need to repaint the
 parent of the repeater.


 On Thu, Aug 2, 2012 at 12:37 PM, Martin Grigorov mgrigo...@apache.org 
 wrote:
 On Thu, Aug 2, 2012 at 3:25 AM, Benjamin Heiskell
 ben.heisk...@gmail.com wrote:
 Hi,

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

 For dynamic add/remove of a single item see :
 https://github.com/vineetsemwal/quickview/wiki


 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-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




 --
 Martin Grigorov
 jWeekend
 Training, Consulting, Development
 http://jWeekend.com

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




 --
 regards,

 Vineet Semwal

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




 --
 Martin Grigorov
 jWeekend
 Training, Consulting, Development
 http://jWeekend.com

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




-- 
regards,

Vineet Semwal

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



Re: Repeating TextFields

2012-08-06 Thread vineet semwal
sorry i misread again :),i assumed you meant for more than one item
the parent has to be repainted .

On Mon, Aug 6, 2012 at 3:45 PM, vineet semwal vineetsemwa...@gmail.com wrote:
 quickview *can* add/remove any number of items without the need to
 repaint the parent of repeater,check the examples in the quickview ;)
 ,AjaxItemsNavigator and other new onscroll behaviors which i have
 added recently would not have been possible if quickview was not
 capable of that,they work like click/onscroll to see new rows added
 like what you see in social networking applications...

 On Mon, Aug 6, 2012 at 3:34 PM, Martin Grigorov mgrigo...@apache.org wrote:
 On Mon, Aug 6, 2012 at 12:52 PM, vineet semwal vineetsemwa...@gmail.com 
 wrote:
 actually with quickview you can add/remove any number of items but i
 might have overread/misunderstood what martin is saying..

 Correct!
 I meant to add/remove just items without the need to repaint the
 parent of the repeater.


 On Thu, Aug 2, 2012 at 12:37 PM, Martin Grigorov mgrigo...@apache.org 
 wrote:
 On Thu, Aug 2, 2012 at 3:25 AM, Benjamin Heiskell
 ben.heisk...@gmail.com wrote:
 Hi,

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

 For dynamic add/remove of a single item see :
 https://github.com/vineetsemwal/quickview/wiki


 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-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




 --
 Martin Grigorov
 jWeekend
 Training, Consulting, Development
 http://jWeekend.com

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




 --
 regards,

 Vineet Semwal

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




 --
 Martin Grigorov
 jWeekend
 Training, Consulting, Development
 http://jWeekend.com

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




 --
 regards,

 Vineet Semwal



-- 
regards,

Vineet Semwal

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



Re: Repeating TextFields

2012-08-03 Thread Martin Grigorov
On Thu, Aug 2, 2012 at 3:25 AM, Benjamin Heiskell
ben.heisk...@gmail.com wrote:
 Hi,

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

For dynamic add/remove of a single item see :
https://github.com/vineetsemwal/quickview/wiki


 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-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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



Re: Repeating TextFields

2012-08-02 Thread Andrea Del Bene

Hi,

what kind of problem have you encountered with ListView?

Hi,

I have a ListString 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-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: Repeating TextFields

2012-08-02 Thread Benjamin Heiskell
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 FormComponentPanelListString {

private static final long serialVersionUID = 1L;

private final ListViewString listView;

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

setOutputMarkupId(true);

listView = new ListViewString(list) {
private static final long serialVersionUID = 1L;

@Override
protected void populateItem(final ListItemString item) {
final TextFieldString textField = new
TextFieldString(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((ListString)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 ListItemString item;

public RemoveButton(final String id, final ListItemString 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.delb...@gmail.com wrote:
 Hi,

 what kind of problem have you encountered with ListView?

 Hi,

 I have a ListString 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-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


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



Re: Repeating TextFields

2012-08-02 Thread Sven Meier
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 FormComponentPanelListString {

 private static final long serialVersionUID = 1L;

 private final ListViewString listView;

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

 setOutputMarkupId(true);

 listView = new ListViewString(list) {
 private static final long serialVersionUID = 1L;

 @Override
 protected void populateItem(final ListItemString item) {
 final TextFieldString textField = new
TextFieldString(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((ListString)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 ListItemString item;

 public RemoveButton(final String id, final ListItemString 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.delb...@gmail.com wrote:

Hi,

what kind of problem have you encountered with ListView?

Hi,

I have a ListString 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-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


-
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: Repeating TextFields

2012-08-02 Thread Benjamin Heiskell
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 s...@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 FormComponentPanelListString {

  private static final long serialVersionUID = 1L;

  private final ListViewString listView;

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

  setOutputMarkupId(true);

  listView = new ListViewString(list) {
  private static final long serialVersionUID = 1L;

  @Override
  protected void populateItem(final ListItemString item) {
  final TextFieldString textField = new
 TextFieldString(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((ListString)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 ListItemString item;

  public RemoveButton(final String id, final ListItemString 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.delb...@gmail.com
 wrote:

 Hi,

 what kind of problem have you encountered with ListView?

 Hi,

 I have a ListString 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-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

 -
 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


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

Re: Repeating TextFields

2012-08-02 Thread Sven Meier

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 s...@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 FormComponentPanelListString {

  private static final long serialVersionUID = 1L;

  private final ListViewString listView;

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

  setOutputMarkupId(true);

  listView = new ListViewString(list) {
  private static final long serialVersionUID = 1L;

  @Override
  protected void populateItem(final ListItemString item) {
  final TextFieldString textField = new
TextFieldString(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((ListString)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 ListItemString item;

  public RemoveButton(final String id, final ListItemString 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.delb...@gmail.com
wrote:

Hi,

what kind of problem have you encountered with ListView?

Hi,

I have a ListString 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-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


-
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: Repeating TextFields

2012-08-02 Thread Benjamin Heiskell
Thank you, that's exactly the type of advice I was looking for!

On Thu, Aug 2, 2012 at 2:55 PM, Sven Meier s...@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 s...@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 FormComponentPanelListString
 {

   private static final long serialVersionUID = 1L;

   private final ListViewString listView;

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

   setOutputMarkupId(true);

   listView = new ListViewString(list) {
   private static final long serialVersionUID = 1L;

   @Override
   protected void populateItem(final ListItemString item) {
   final TextFieldString textField = new
 TextFieldString(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((ListString)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 ListItemString item;

   public RemoveButton(final String id, final ListItemString
 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.delb...@gmail.com
 wrote:

 Hi,

 what kind of problem have you encountered with ListView?

 Hi,

 I have a ListString 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-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

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

RE: Repeating TextFields

2012-08-01 Thread Paul Bors
I use DataTable and add a new object to its model.
Another thing I do is to allow for an edit button that would turn the entire
row of a DataTable into the appropriate form fields.

For a visual see the Editable tree table from wicket's examples at:
http://www.wicket-library.com/wicket
-examples/nested/wicket/bookmarkable/org.apache.wicket.examples.ajax.builtin
.tree.EditableTreeTablePage?2

-Original Message-
From: Benjamin Heiskell [mailto:ben.heisk...@gmail.com] 
Sent: Wednesday, August 01, 2012 8:26 PM
To: users@wicket.apache.org
Subject: Repeating TextFields

Hi,

I have a ListString 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-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: Repeating TextFields

2012-08-01 Thread Sven Meier
There's nothing wrong with using TextFields inside ListViews. Just call 
#setReuseItems(true) and (in most cases) you're done.


And if you're using a LDM, detach it after you've changed the backing list.

Sven

On 08/02/2012 02:25 AM, Benjamin Heiskell wrote:

Hi,

I have a ListString 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-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