Re: How to delete an item from List view.

2010-03-17 Thread prati

Hi

I have got a refreshingView with a delete link in each row and only one
AddLink,AddLink adds the 

row properly but deleteRow everytime deletes the last row,its driving me
crazy,I have posted my 

code also.I will apprecaite if any one can help me in this.

Honestly its not that easy the way it seams.


Thanks

Prati 



prati wrote:
 
 Hi,
 
 I am also having similar issue, it all the time removes last row.
 I have attached code.
 
 
 OptionGroupPageForm(String id) {
 
   super(id);
 
   final MarkupContainer rowPanel = new 
 WebMarkupContainer(rowPanel);
   rowPanel.setOutputMarkupId(true);
   add(rowPanel);
 
   // List all rows
 
 
   rows.add(new String());
 
   RefreshingView lv = new RefreshingView(rows) {
 
   @Override
   protected IteratorIModel getItemModels()
   {
   List models = new ArrayList();
 
   for(int i=0;irows.size();i++){
   models.add(new Model( (String) 
 rows.get(i)));
   }
 
   return models.iterator(); 
   //return rows.iterator();
   }
 
   @Override
   protected void populateItem(final Item item) {
 
   int index = item.getIndex() + 1;
 
   item.add(new Label(index, 
 Option+index + .));
 
   TextField text = new TextField(text, 
 item.getModel());
 
   RadioChoice rc = new 
 RadioChoice(status, STATUS);
 
   item.add(text);
 
   item.add(rc);
 
   item.add(new AjaxLink(removeRow) {
 
   @Override
   public void 
 onClick(AjaxRequestTarget target) {
 
 
   
 
   if (target != null) {
   
 target.addComponent(rowPanel);
   }
   }
   } );
   }
   };
 
   
 lv.setItemReuseStrategy(ReuseIfModelsEqualStrategy.getInstance());
   rowPanel.add(lv);
 
   AjaxSubmitLink addLink = new AjaxSubmitLink(addRow, 
 this) {
   @Override
   public void onSubmit(AjaxRequestTarget target, 
 Form form) {
 
   rows.add(new String());
 
 
 
   if (target != null)
   target.addComponent(rowPanel);
   }
   };
 
   addLink.setDefaultFormProcessing(false);
 
   add(addLink);
 
 
 
 
   }
 
 Thanks
 
  Prati
 
 Johan Compagner wrote:
 
 You do use a delete button, so i guess the values are submitted.
 Then if you store those first in the model objects you won't loose
 anything
 
 johan
 
 
 
 On Feb 4, 2008 2:35 PM, pnerkar pner...@gmail.com wrote:
 

 Hi Johan,

 Yes that will be quickest solution ,
 But this will clear the fields of all vehicles.

 -Pnerkar


 Johan Compagner wrote:
 
  wasn't the quickest solution:
 
  public void onSubmit() {
 List vehicles = (List)
 getParent().getParent().getModelObject();
 vehicles.remove(index);
 listView.removeAll();
  }
 
  Then if the list itself is stable on the server side (if other persons
 can
  also delete or add stuff to that list you really should do it
 differently)
  that should work fine. After you alter the listviews model you have to
  remove all the items so that it will rebuild
 
  johan
 
 
 
 
  On Feb 1, 2008 12:49 AM, pnerkar pner...@gmail.com wrote:
 
 
  Hi All,
 
  I have rendered a list view on a Web Page.
 
  vehicle1X
  vehicle2X
  vehicle3X
 
  when a person click on 'X', that item should be deleted.
  But I'm facing an issue, when i click on 'X', last item get deleted.
  Actually when I delete vehicle2 from my list, it deletes vehicle2 but
  that
  component is still there.
  So while rendering it render vehicle1  vehicle2.
 
  public void onSubmit() {
 List vehicles = (List)
 getParent().getParent().getModelObject();
 vehicles.remove(index);
  }
 
  can please 

Re: How to delete an item from List view.

2010-03-17 Thread prati

Hi Team,

Also i dont want to remove values , i want to remove the entire row.
My row contains(TextBox and option group)


Thanks
Prati


prati wrote:
 
 Hi
 
 I have got a refreshingView with a delete link in each row and only one
 AddLink,AddLink adds the 
 
 row properly but deleteRow everytime deletes the last row,its driving me
 crazy,I have posted my 
 
 code also.I will apprecaite if any one can help me in this.
 
 Honestly its not that easy the way it seams.
 
 
 Thanks
 
 Prati 
 
 
 
 prati wrote:
 
 Hi,
 
 I am also having similar issue, it all the time removes last row.
 I have attached code.
 
 
 OptionGroupPageForm(String id) {
 
  super(id);
 
  final MarkupContainer rowPanel = new 
 WebMarkupContainer(rowPanel);
  rowPanel.setOutputMarkupId(true);
  add(rowPanel);
 
  // List all rows
 
 
  rows.add(new String());
 
  RefreshingView lv = new RefreshingView(rows) {
 
  @Override
  protected IteratorIModel getItemModels()
  {
  List models = new ArrayList();
 
  for(int i=0;irows.size();i++){
  models.add(new Model( (String) 
 rows.get(i)));
  }
 
  return models.iterator(); 
  //return rows.iterator();
  }
 
  @Override
  protected void populateItem(final Item item) {
 
  int index = item.getIndex() + 1;
 
  item.add(new Label(index, 
 Option+index + .));
 
  TextField text = new TextField(text, 
 item.getModel());
 
  RadioChoice rc = new 
 RadioChoice(status, STATUS);
 
  item.add(text);
 
  item.add(rc);
 
  item.add(new AjaxLink(removeRow) {
 
  @Override
  public void 
 onClick(AjaxRequestTarget target) {
 
 
  
 
  if (target != null) {
  
 target.addComponent(rowPanel);
  }
  }
  } );
  }
  };
 
  
 lv.setItemReuseStrategy(ReuseIfModelsEqualStrategy.getInstance());
  rowPanel.add(lv);
 
  AjaxSubmitLink addLink = new AjaxSubmitLink(addRow, 
 this) {
  @Override
  public void onSubmit(AjaxRequestTarget target, 
 Form form) {
 
  rows.add(new String());
 
 
 
  if (target != null)
  target.addComponent(rowPanel);
  }
  };
 
  addLink.setDefaultFormProcessing(false);
 
  add(addLink);
 
 
 
 
  }
 
 Thanks
 
  Prati
 
 Johan Compagner wrote:
 
 You do use a delete button, so i guess the values are submitted.
 Then if you store those first in the model objects you won't loose
 anything
 
 johan
 
 
 
 On Feb 4, 2008 2:35 PM, pnerkar pner...@gmail.com wrote:
 

 Hi Johan,

 Yes that will be quickest solution ,
 But this will clear the fields of all vehicles.

 -Pnerkar


 Johan Compagner wrote:
 
  wasn't the quickest solution:
 
  public void onSubmit() {
 List vehicles = (List)
 getParent().getParent().getModelObject();
 vehicles.remove(index);
 listView.removeAll();
  }
 
  Then if the list itself is stable on the server side (if other
 persons
 can
  also delete or add stuff to that list you really should do it
 differently)
  that should work fine. After you alter the listviews model you have
 to
  remove all the items so that it will rebuild
 
  johan
 
 
 
 
  On Feb 1, 2008 12:49 AM, pnerkar pner...@gmail.com wrote:
 
 
  Hi All,
 
  I have rendered a list view on a Web Page.
 
  vehicle1X
  vehicle2X
  vehicle3X
 
  when a person click on 'X', that item should be deleted.
  But I'm facing an issue, when i click on 'X', last item get deleted.
  Actually when I delete vehicle2 from my list, it deletes vehicle2
 but
  that
  component is still there.
  So while rendering it render vehicle1  vehicle2.
 
  public void onSubmit() {

Re: How to delete an item from List view.

2010-03-17 Thread Major Péter
Hi,

Been there, pal, believe me, been there. :))
See https://issues.apache.org/jira/browse/WICKET-2432 quickstart.zip
Remove the FileUpload and this should do it for you. :)

Best Regards,
Peter

2010-03-17 15:10 keltezéssel, prati írta:
 
 Hi
 
 I have got a refreshingView with a delete link in each row and only one
 AddLink,AddLink adds the 
 
 row properly but deleteRow everytime deletes the last row,its driving me
 crazy,I have posted my 
 
 code also.I will apprecaite if any one can help me in this.
 
 Honestly its not that easy the way it seams.
 
 
 Thanks
 
 Prati 
 
 
 
 prati wrote:

 Hi,

 I am also having similar issue, it all the time removes last row.
 I have attached code.


 OptionGroupPageForm(String id) {

  super(id);

  final MarkupContainer rowPanel = new 
 WebMarkupContainer(rowPanel);
  rowPanel.setOutputMarkupId(true);
  add(rowPanel);

  // List all rows


  rows.add(new String());

  RefreshingView lv = new RefreshingView(rows) {

  @Override
  protected IteratorIModel getItemModels()
  {
  List models = new ArrayList();

  for(int i=0;irows.size();i++){
  models.add(new Model( (String) 
 rows.get(i)));
  }

  return models.iterator(); 
  //return rows.iterator();
  }

  @Override
  protected void populateItem(final Item item) {

  int index = item.getIndex() + 1;

  item.add(new Label(index, 
 Option+index + .));

  TextField text = new TextField(text, 
 item.getModel());

  RadioChoice rc = new 
 RadioChoice(status, STATUS);

  item.add(text);

  item.add(rc);

  item.add(new AjaxLink(removeRow) {

  @Override
  public void 
 onClick(AjaxRequestTarget target) {


  

  if (target != null) {
  
 target.addComponent(rowPanel);
  }
  }
  } );
  }
  };

  
 lv.setItemReuseStrategy(ReuseIfModelsEqualStrategy.getInstance());
  rowPanel.add(lv);

  AjaxSubmitLink addLink = new AjaxSubmitLink(addRow, 
 this) {
  @Override
  public void onSubmit(AjaxRequestTarget target, 
 Form form) {

  rows.add(new String());



  if (target != null)
  target.addComponent(rowPanel);
  }
  };

  addLink.setDefaultFormProcessing(false);

  add(addLink);




  }

 Thanks

  Prati

 Johan Compagner wrote:

 You do use a delete button, so i guess the values are submitted.
 Then if you store those first in the model objects you won't loose
 anything

 johan



 On Feb 4, 2008 2:35 PM, pnerkar pner...@gmail.com wrote:


 Hi Johan,

 Yes that will be quickest solution ,
 But this will clear the fields of all vehicles.

 -Pnerkar


 Johan Compagner wrote:

 wasn't the quickest solution:

 public void onSubmit() {
List vehicles = (List)
 getParent().getParent().getModelObject();
vehicles.remove(index);
listView.removeAll();
 }

 Then if the list itself is stable on the server side (if other persons
 can
 also delete or add stuff to that list you really should do it
 differently)
 that should work fine. After you alter the listviews model you have to
 remove all the items so that it will rebuild

 johan




 On Feb 1, 2008 12:49 AM, pnerkar pner...@gmail.com wrote:


 Hi All,

 I have rendered a list view on a Web Page.

 vehicle1X
 vehicle2X
 vehicle3X

 when a person click on 'X', that item should be deleted.
 But I'm facing an issue, when i click on 'X', last item get deleted.
 Actually when I delete vehicle2 from my list, it deletes vehicle2 but
 that
 component is still there.
 So while rendering it render vehicle1  vehicle2.

 public void onSubmit() {

Re: How to delete an item from List view.

2010-03-17 Thread prati

Hi ListView/Refreshing View any willd o

but dont know how to solve this.

Thanks
P

prati wrote:
 
 Hi Team,
 
 Also i dont want to remove values , i want to remove the entire row.
 My row contains(TextBox and option group)
 
 
 Thanks
 Prati
 
 
 prati wrote:
 
 Hi
 
 I have got a refreshingView with a delete link in each row and only one
 AddLink,AddLink adds the 
 
 row properly but deleteRow everytime deletes the last row,its driving me
 crazy,I have posted my 
 
 code also.I will apprecaite if any one can help me in this.
 
 Honestly its not that easy the way it seams.
 
 
 Thanks
 
 Prati 
 
 
 
 prati wrote:
 
 Hi,
 
 I am also having similar issue, it all the time removes last row.
 I have attached code.
 
 
 OptionGroupPageForm(String id) {
 
 super(id);
 
 final MarkupContainer rowPanel = new 
 WebMarkupContainer(rowPanel);
 rowPanel.setOutputMarkupId(true);
 add(rowPanel);
 
 // List all rows
 
 
 rows.add(new String());
 
 RefreshingView lv = new RefreshingView(rows) {
 
 @Override
 protected IteratorIModel getItemModels()
 {
 List models = new ArrayList();
 
 for(int i=0;irows.size();i++){
 models.add(new Model( (String) 
 rows.get(i)));
 }
 
 return models.iterator(); 
 //return rows.iterator();
 }
 
 @Override
 protected void populateItem(final Item item) {
 
 int index = item.getIndex() + 1;
 
 item.add(new Label(index, 
 Option+index + .));
 
 TextField text = new TextField(text, 
 item.getModel());
 
 RadioChoice rc = new 
 RadioChoice(status, STATUS);
 
 item.add(text);
 
 item.add(rc);
 
 item.add(new AjaxLink(removeRow) {
 
 @Override
 public void 
 onClick(AjaxRequestTarget target) {
 
 
 
 
 if (target != null) {
 
 target.addComponent(rowPanel);
 }
 }
 } );
 }
 };
 
 
 lv.setItemReuseStrategy(ReuseIfModelsEqualStrategy.getInstance());
 rowPanel.add(lv);
 
 AjaxSubmitLink addLink = new AjaxSubmitLink(addRow, 
 this) {
 @Override
 public void onSubmit(AjaxRequestTarget target, 
 Form form) {
 
 rows.add(new String());
 
 
 
 if (target != null)
 target.addComponent(rowPanel);
 }
 };
 
 addLink.setDefaultFormProcessing(false);
 
 add(addLink);
 
 
 
 
 }
 
 Thanks
 
  Prati
 
 Johan Compagner wrote:
 
 You do use a delete button, so i guess the values are submitted.
 Then if you store those first in the model objects you won't loose
 anything
 
 johan
 
 
 
 On Feb 4, 2008 2:35 PM, pnerkar pner...@gmail.com wrote:
 

 Hi Johan,

 Yes that will be quickest solution ,
 But this will clear the fields of all vehicles.

 -Pnerkar


 Johan Compagner wrote:
 
  wasn't the quickest solution:
 
  public void onSubmit() {
 List vehicles = (List)
 getParent().getParent().getModelObject();
 vehicles.remove(index);
 listView.removeAll();
  }
 
  Then if the list itself is stable on the server side (if other
 persons
 can
  also delete or add stuff to that list you really should do it
 differently)
  that should work fine. After you alter the listviews model you have
 to
  remove all the items so that it will rebuild
 
  johan
 
 
 
 
  On Feb 1, 2008 12:49 AM, pnerkar pner...@gmail.com wrote:
 
 
  Hi All,
 
  I have rendered a list view on a Web Page.
 
  vehicle1X
  vehicle2X
  vehicle3X
 
  when a person click on 'X', that item should be deleted.
  But I'm facing an issue, when i click on 'X', last item get
 deleted.
  Actually when I delete vehicle2 from my list, it deletes vehicle2
 but
  that
  component is still there.
  So while 

Re: How to delete an item from List view.

2010-03-15 Thread prati

Hi,

I am also having similar issue, it all the time removes last row.
I have attached code.


OptionGroupPageForm(String id) {

super(id);

final MarkupContainer rowPanel = new 
WebMarkupContainer(rowPanel);
rowPanel.setOutputMarkupId(true);
add(rowPanel);

// List all rows


rows.add(new String());

RefreshingView lv = new RefreshingView(rows) {

@Override
protected IteratorIModel getItemModels()
{
List models = new ArrayList();

for(int i=0;irows.size();i++){
models.add(new Model( (String) 
rows.get(i)));
}

return models.iterator(); 
//return rows.iterator();
}

@Override
protected void populateItem(final Item item) {

int index = item.getIndex() + 1;

item.add(new Label(index, 
Option+index + .));

TextField text = new TextField(text, 
item.getModel());

RadioChoice rc = new 
RadioChoice(status, STATUS);

item.add(text);

item.add(rc);

item.add(new AjaxLink(removeRow) {

@Override
public void 
onClick(AjaxRequestTarget target) {




if (target != null) {

target.addComponent(rowPanel);
}
}
} );
}
};


lv.setItemReuseStrategy(ReuseIfModelsEqualStrategy.getInstance());
rowPanel.add(lv);

AjaxSubmitLink addLink = new AjaxSubmitLink(addRow, 
this) {
@Override
public void onSubmit(AjaxRequestTarget target, 
Form form) {

rows.add(new String());



if (target != null)
target.addComponent(rowPanel);
}
};

addLink.setDefaultFormProcessing(false);

add(addLink);




}

Thanks

 Prati

Johan Compagner wrote:
 
 You do use a delete button, so i guess the values are submitted.
 Then if you store those first in the model objects you won't loose
 anything
 
 johan
 
 
 
 On Feb 4, 2008 2:35 PM, pnerkar pner...@gmail.com wrote:
 

 Hi Johan,

 Yes that will be quickest solution ,
 But this will clear the fields of all vehicles.

 -Pnerkar


 Johan Compagner wrote:
 
  wasn't the quickest solution:
 
  public void onSubmit() {
 List vehicles = (List) getParent().getParent().getModelObject();
 vehicles.remove(index);
 listView.removeAll();
  }
 
  Then if the list itself is stable on the server side (if other persons
 can
  also delete or add stuff to that list you really should do it
 differently)
  that should work fine. After you alter the listviews model you have to
  remove all the items so that it will rebuild
 
  johan
 
 
 
 
  On Feb 1, 2008 12:49 AM, pnerkar pner...@gmail.com wrote:
 
 
  Hi All,
 
  I have rendered a list view on a Web Page.
 
  vehicle1X
  vehicle2X
  vehicle3X
 
  when a person click on 'X', that item should be deleted.
  But I'm facing an issue, when i click on 'X', last item get deleted.
  Actually when I delete vehicle2 from my list, it deletes vehicle2 but
  that
  component is still there.
  So while rendering it render vehicle1  vehicle2.
 
  public void onSubmit() {
 List vehicles = (List)
 getParent().getParent().getModelObject();
 vehicles.remove(index);
  }
 
  can please help out ??
 
 
 
  --
  View this message in context:
 
 http://www.nabble.com/How-to-delete-an-item-from-List-view.-tp15217608p15217608.html
  Sent from the Wicket - User mailing list archive at
  Nabble.com http://nabble.com/http://nabble.com/
  .
 
 
  -
  To unsubscribe, 

Re: How to delete an item from List view.

2008-02-04 Thread Johan Compagner
You do use a delete button, so i guess the values are submitted.
Then if you store those first in the model objects you won't loose anything

johan



On Feb 4, 2008 2:35 PM, pnerkar [EMAIL PROTECTED] wrote:


 Hi Johan,

 Yes that will be quickest solution ,
 But this will clear the fields of all vehicles.

 -Pnerkar


 Johan Compagner wrote:
 
  wasn't the quickest solution:
 
  public void onSubmit() {
 List vehicles = (List) getParent().getParent().getModelObject();
 vehicles.remove(index);
 listView.removeAll();
  }
 
  Then if the list itself is stable on the server side (if other persons
 can
  also delete or add stuff to that list you really should do it
 differently)
  that should work fine. After you alter the listviews model you have to
  remove all the items so that it will rebuild
 
  johan
 
 
 
 
  On Feb 1, 2008 12:49 AM, pnerkar [EMAIL PROTECTED] wrote:
 
 
  Hi All,
 
  I have rendered a list view on a Web Page.
 
  vehicle1X
  vehicle2X
  vehicle3X
 
  when a person click on 'X', that item should be deleted.
  But I'm facing an issue, when i click on 'X', last item get deleted.
  Actually when I delete vehicle2 from my list, it deletes vehicle2 but
  that
  component is still there.
  So while rendering it render vehicle1  vehicle2.
 
  public void onSubmit() {
 List vehicles = (List) getParent().getParent().getModelObject();
 vehicles.remove(index);
  }
 
  can please help out ??
 
 
 
  --
  View this message in context:
 
 http://www.nabble.com/How-to-delete-an-item-from-List-view.-tp15217608p15217608.html
  Sent from the Wicket - User mailing list archive at
  Nabble.com http://nabble.com/http://nabble.com/
  .
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 

 --
 View this message in context:
 http://www.nabble.com/How-to-delete-an-item-from-List-view.-tp15217608p15268198.html
  Sent from the Wicket - User mailing list archive at 
 Nabble.comhttp://nabble.com/
 .


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




Re: How to delete an item from List view.

2008-02-04 Thread Eelco Hillenius
On Feb 4, 2008 3:45 AM, Martijn Dashorst [EMAIL PROTECTED] wrote:
 On 2/3/08, Eelco Hillenius [EMAIL PROTECTED] wrote:
 
  How about a reconsideration of depreciating ListView?


 -1

 If anytime someone comes along with a misunderstanding of a valid component
 we don't have a framework left:
  - models
  - drop down choice
  - urls
  - mounting

 All those things can be deprecated then.

Not true. There are perfectly complete replacements for ListView, not
for the other things you mention.

Eelco

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to delete an item from List view.

2008-02-04 Thread Johan Compagner
wasn't the quickest solution:

public void onSubmit() {
   List vehicles = (List) getParent().getParent().getModelObject();
   vehicles.remove(index);
   listView.removeAll();
}

Then if the list itself is stable on the server side (if other persons can
also delete or add stuff to that list you really should do it differently)
that should work fine. After you alter the listviews model you have to
remove all the items so that it will rebuild

johan




On Feb 1, 2008 12:49 AM, pnerkar [EMAIL PROTECTED] wrote:


 Hi All,

 I have rendered a list view on a Web Page.

 vehicle1X
 vehicle2X
 vehicle3X

 when a person click on 'X', that item should be deleted.
 But I'm facing an issue, when i click on 'X', last item get deleted.
 Actually when I delete vehicle2 from my list, it deletes vehicle2 but that
 component is still there.
 So while rendering it render vehicle1  vehicle2.

 public void onSubmit() {
List vehicles = (List) getParent().getParent().getModelObject();
vehicles.remove(index);
 }

 can please help out ??



 --
 View this message in context:
 http://www.nabble.com/How-to-delete-an-item-from-List-view.-tp15217608p15217608.html
 Sent from the Wicket - User mailing list archive at 
 Nabble.comhttp://nabble.com/
 .


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




Re: How to delete an item from List view.

2008-02-04 Thread Martijn Dashorst
On 2/3/08, Eelco Hillenius [EMAIL PROTECTED] wrote:

 How about a reconsideration of depreciating ListView?


-1

If anytime someone comes along with a misunderstanding of a valid component
we don't have a framework left:
 - models
 - drop down choice
 - urls
 - mounting

All those things can be deprecated then.

Martijn

-- 
Buy Wicket in Action: http://manning.com/dashorst
Apache Wicket 1.3.0 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.0


Re: How to delete an item from List view.

2008-02-04 Thread pnerkar

Hi Johan,

Yes that will be quickest solution , 
But this will clear the fields of all vehicles.

-Pnerkar


Johan Compagner wrote:
 
 wasn't the quickest solution:
 
 public void onSubmit() {
List vehicles = (List) getParent().getParent().getModelObject();
vehicles.remove(index);
listView.removeAll();
 }
 
 Then if the list itself is stable on the server side (if other persons can
 also delete or add stuff to that list you really should do it differently)
 that should work fine. After you alter the listviews model you have to
 remove all the items so that it will rebuild
 
 johan
 
 
 
 
 On Feb 1, 2008 12:49 AM, pnerkar [EMAIL PROTECTED] wrote:
 

 Hi All,

 I have rendered a list view on a Web Page.

 vehicle1X
 vehicle2X
 vehicle3X

 when a person click on 'X', that item should be deleted.
 But I'm facing an issue, when i click on 'X', last item get deleted.
 Actually when I delete vehicle2 from my list, it deletes vehicle2 but
 that
 component is still there.
 So while rendering it render vehicle1  vehicle2.

 public void onSubmit() {
List vehicles = (List) getParent().getParent().getModelObject();
vehicles.remove(index);
 }

 can please help out ??



 --
 View this message in context:
 http://www.nabble.com/How-to-delete-an-item-from-List-view.-tp15217608p15217608.html
 Sent from the Wicket - User mailing list archive at
 Nabble.comhttp://nabble.com/
 .


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]


 
 

-- 
View this message in context: 
http://www.nabble.com/How-to-delete-an-item-from-List-view.-tp15217608p15268198.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to delete an item from List view.

2008-02-04 Thread Igor Vaynberg
you lose values that werent validated if you do that, because those
are stored in components themselves...

-igor


On Feb 4, 2008 6:15 AM, Johan Compagner [EMAIL PROTECTED] wrote:
 You do use a delete button, so i guess the values are submitted.
 Then if you store those first in the model objects you won't loose anything

 johan




 On Feb 4, 2008 2:35 PM, pnerkar [EMAIL PROTECTED] wrote:

 
  Hi Johan,
 
  Yes that will be quickest solution ,
  But this will clear the fields of all vehicles.
 
  -Pnerkar
 
 
  Johan Compagner wrote:
  
   wasn't the quickest solution:
  
   public void onSubmit() {
  List vehicles = (List) getParent().getParent().getModelObject();
  vehicles.remove(index);
  listView.removeAll();
   }
  
   Then if the list itself is stable on the server side (if other persons
  can
   also delete or add stuff to that list you really should do it
  differently)
   that should work fine. After you alter the listviews model you have to
   remove all the items so that it will rebuild
  
   johan
  
  
  
  
   On Feb 1, 2008 12:49 AM, pnerkar [EMAIL PROTECTED] wrote:
  
  
   Hi All,
  
   I have rendered a list view on a Web Page.
  
   vehicle1X
   vehicle2X
   vehicle3X
  
   when a person click on 'X', that item should be deleted.
   But I'm facing an issue, when i click on 'X', last item get deleted.
   Actually when I delete vehicle2 from my list, it deletes vehicle2 but
   that
   component is still there.
   So while rendering it render vehicle1  vehicle2.
  
   public void onSubmit() {
  List vehicles = (List) getParent().getParent().getModelObject();
  vehicles.remove(index);
   }
  
   can please help out ??
  
  
  
   --
   View this message in context:
  
  http://www.nabble.com/How-to-delete-an-item-from-List-view.-tp15217608p15217608.html
   Sent from the Wicket - User mailing list archive at
   Nabble.com http://nabble.com/http://nabble.com/
   .
  
  
   -
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  
  
  
 
  --
  View this message in context:
  http://www.nabble.com/How-to-delete-an-item-from-List-view.-tp15217608p15268198.html
   Sent from the Wicket - User mailing list archive at 
  Nabble.comhttp://nabble.com/

  .
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to delete an item from List view.

2008-02-04 Thread Nino Saturnino Martinez Vazquez Wael
I've come to love listview, and use it all the time. Would be sad to see 
it go away.. Sure there are somethinges you need to be aware of when 
working with it but thats just life...


-1

Eelco Hillenius wrote:

On Feb 4, 2008 3:45 AM, Martijn Dashorst [EMAIL PROTECTED] wrote:
  

On 2/3/08, Eelco Hillenius [EMAIL PROTECTED] wrote:


How about a reconsideration of depreciating ListView?
  

-1

If anytime someone comes along with a misunderstanding of a valid component
we don't have a framework left:
 - models
 - drop down choice
 - urls
 - mounting

All those things can be deprecated then.



Not true. There are perfectly complete replacements for ListView, not
for the other things you mention.

Eelco

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


  


--
Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to delete an item from List view.

2008-02-02 Thread Alan Romaniuc
Hi all,

I know that will be sound a little stupid, but ListView causes  a lot
of problems for newbies (including reuse startegy). Maybe a better or
more in depth wiki entry would avoid these questions on this mail
list? Just a suggestion (once i am facing the same probles, i would
not be the right person to do that :( )


On Feb 2, 2008 12:01 AM, Igor Vaynberg [EMAIL PROTECTED] wrote:
 read the notice part of the javadoc...

 -igor



 On Feb 1, 2008 5:49 PM, pnerkar [EMAIL PROTECTED] wrote:
 
  Hi igor,
 
  Ya I read this from one of ur doc.
  http://www.wicketframework.org/wicket-extensions/apidocs/wicket/extensions/markup/html/repeater/refreshing/ReuseIfModelsEqualStrategy.html
  I have implemented equals/hashcode in Vehicle object.
 
  -pnerkar
 
 
 
  igor.vaynberg wrote:
  
   for the strategy to work properly you have to implement
   equals/hashcode on the model, looks like you are just doing:
  
   new Model( (Vehicle) ((List)getModelObject()).get(i))
  
   Model does not implement equals/hashcode
  
   -igor
  
  
   On Feb 1, 2008 4:03 PM, pnerkar [EMAIL PROTECTED] wrote:
  
   Ya I tried refreshingview with ReuseIfModelsEqualStrategy,
   But the data entered on page get cleared.
  
   My new code is -
  
  
   final VehiclesList vehicles = new VehiclesList(vehicles, new
   PropertyModel((RatingRequestAuto)getModelObject(),vehicles));
   vehicles.setOutputMarkupId(true);
   vehicles.setItemReuseStrategy(new ReuseIfModelsEqualStrategy());
   add(vehicles);
  
   private static class VehiclesList extends RefreshingView {
  
  
   public VehiclesList (String id, PropertyModel model) {
   super (id,model);
   }
  
 /**
* Return an iterator over models for items in the view
*/
   protected Iterator getItemModels()
   {
   List models = new ArrayList();
   for(int
   i=0;i((List)getModelObject()).size();i++){
   models.add(new Model( (Vehicle)
   ((List)getModelObject()).get(i)));
   }
   return models.iterator();
   }
  
   protected void populateItem(final ListItem item)
{
  
   item.add(new TextField(vehicle.modelText, new
   PropertyModel(vehicle, model)).setRequired(true));
   TextField registrationnumber = new
   TextField(vehicle.registrationnumber, new PropertyModel(vehicle,
   registrationNumber));
   TextField engineNumber = new
   TextField(vehicle.enginenumber, new
   PropertyModel(vehicle, engineNumber));
  
   final int index = item.getIndex();
   Button remVehBtn = new
   Button(btn_removeVeh, new ResourceModel(
   removevehicle )) {
   public void onSubmit() {
  
   item.getParent().remove(item);
   }
   });
   }
   }
   }
  
   forgive me this may not be a cleaner way... I dont have more than a month
   exp of wicket.
  
   -pnerkar
  
  
  
  
   igor.vaynberg wrote:
   
dont use a listview, use a refreshingview and provide an itemreuse
strategy.
   
-igor
   
   
On Feb 1, 2008 1:51 PM, pnerkar [EMAIL PROTECTED] wrote:
   
Hi Igor,
   
Finally I'm able to find out the exact issue.
suppose There are 3 items in the list-
wicket will assign id as 0, 1  2. to those items.
So When we say  item.getparent().remove(item) to item with id=1,
them It'll remove that item from list but item with id=2 will not
   remain
as
it is..
i.e.  Now list will have 2 items one with id=0  id=2.
So when we display list, it'll clears the fields for item with id=1.
so we need to update id field of item object... But think there is no
   way
to
do that...
   
is there...???
   
-Pnerkar
   
   
   
   
igor.vaynberg wrote:

 try this:

 onpopulate (final listitem item) {
add(new link(remove) { onclick() { 
 item.getparent().remove(item); }}
 }

 -igor


 On Jan 31, 2008 6:19 PM, pnerkar [EMAIL PROTECTED] wrote:

 Hi igor,

 But If I remove setReuseItems(true), it'll remove all field values
which
 user has entered will be removed.
 Bcz default processing  is false for Remove button (Sorry forget to
tell
 you)
 I just want to remove vehicle2, but the values entered for vehicle1
   
 vehicle3 should not be lost.


 - Pnerkar





 igor.vaynberg wrote:
 
  vehicles.setReuseItems(true); == that is what is causing your
   list
to
  reuse old 

Re: How to delete an item from List view.

2008-02-02 Thread Igor Vaynberg
well, thats the problem. you say you are not the right person because
you dont know. and that is the excuse a lot of users give for not
writing the wiki page. but guess what, after we help them here and
they do understand how listview works - they still dont come back and
write the wiki page.

so there you go, welcome to open source...

-igor


On Feb 2, 2008 12:44 PM, Alan Romaniuc [EMAIL PROTECTED] wrote:
 Hi all,

 I know that will be sound a little stupid, but ListView causes  a lot
 of problems for newbies (including reuse startegy). Maybe a better or
 more in depth wiki entry would avoid these questions on this mail
 list? Just a suggestion (once i am facing the same probles, i would
 not be the right person to do that :( )



 On Feb 2, 2008 12:01 AM, Igor Vaynberg [EMAIL PROTECTED] wrote:
  read the notice part of the javadoc...
 
  -igor
 
 
 
  On Feb 1, 2008 5:49 PM, pnerkar [EMAIL PROTECTED] wrote:
  
   Hi igor,
  
   Ya I read this from one of ur doc.
   http://www.wicketframework.org/wicket-extensions/apidocs/wicket/extensions/markup/html/repeater/refreshing/ReuseIfModelsEqualStrategy.html
   I have implemented equals/hashcode in Vehicle object.
  
   -pnerkar
  
  
  
   igor.vaynberg wrote:
   
for the strategy to work properly you have to implement
equals/hashcode on the model, looks like you are just doing:
   
new Model( (Vehicle) ((List)getModelObject()).get(i))
   
Model does not implement equals/hashcode
   
-igor
   
   
On Feb 1, 2008 4:03 PM, pnerkar [EMAIL PROTECTED] wrote:
   
Ya I tried refreshingview with ReuseIfModelsEqualStrategy,
But the data entered on page get cleared.
   
My new code is -
   
   
final VehiclesList vehicles = new VehiclesList(vehicles, new
PropertyModel((RatingRequestAuto)getModelObject(),vehicles));
vehicles.setOutputMarkupId(true);
vehicles.setItemReuseStrategy(new 
ReuseIfModelsEqualStrategy());
add(vehicles);
   
private static class VehiclesList extends RefreshingView {
   
   
public VehiclesList (String id, PropertyModel model) {
super (id,model);
}
   
  /**
 * Return an iterator over models for items in the view
 */
protected Iterator getItemModels()
{
List models = new ArrayList();
for(int
i=0;i((List)getModelObject()).size();i++){
models.add(new Model( (Vehicle)
((List)getModelObject()).get(i)));
}
return models.iterator();
}
   
protected void populateItem(final ListItem item)
 {
   
item.add(new TextField(vehicle.modelText, new
PropertyModel(vehicle, model)).setRequired(true));
TextField registrationnumber = new
TextField(vehicle.registrationnumber, new PropertyModel(vehicle,
registrationNumber));
TextField engineNumber = new
TextField(vehicle.enginenumber, new
PropertyModel(vehicle, engineNumber));
   
final int index = item.getIndex();
Button remVehBtn = new
Button(btn_removeVeh, new ResourceModel(
removevehicle )) {
public void onSubmit() 
{
   
item.getParent().remove(item);
}
});
}
}
}
   
forgive me this may not be a cleaner way... I dont have more than a 
month
exp of wicket.
   
-pnerkar
   
   
   
   
igor.vaynberg wrote:

 dont use a listview, use a refreshingview and provide an itemreuse
 strategy.

 -igor


 On Feb 1, 2008 1:51 PM, pnerkar [EMAIL PROTECTED] wrote:

 Hi Igor,

 Finally I'm able to find out the exact issue.
 suppose There are 3 items in the list-
 wicket will assign id as 0, 1  2. to those items.
 So When we say  item.getparent().remove(item) to item with id=1,
 them It'll remove that item from list but item with id=2 will not
remain
 as
 it is..
 i.e.  Now list will have 2 items one with id=0  id=2.
 So when we display list, it'll clears the fields for item with id=1.
 so we need to update id field of item object... But think there is 
 no
way
 to
 do that...

 is there...???

 -Pnerkar




 igor.vaynberg wrote:
 
  try this:
 
  onpopulate (final listitem item) {
 add(new link(remove) { onclick() { 
  item.getparent().remove(item); }}
  }
 
  -igor
 
 
  On 

Re: How to delete an item from List view.

2008-02-02 Thread Eelco Hillenius
On Feb 2, 2008 2:19 PM, Igor Vaynberg [EMAIL PROTECTED] wrote:
 well, thats the problem. you say you are not the right person because
 you dont know. and that is the excuse a lot of users give for not
 writing the wiki page. but guess what, after we help them here and
 they do understand how listview works - they still dont come back and
 write the wiki page.

Don't be too harsh. There have been quite a few people who wrote for
the WIKI before, and to be honest, I haven't always shared my
experiences with e.g. Hibernate with the rest of the world either.

How about a reconsideration of depreciating ListView?

Eelco

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to delete an item from List view.

2008-02-02 Thread Igor Vaynberg
i dont think i was harsh. i simply stated that the excuse i dont yet
know enough is not really an excuse but a cop out, because most users
dont come back and contribute something. im not angry about it, but it
is a fact.

-igor


On Feb 2, 2008 9:05 PM, Eelco Hillenius [EMAIL PROTECTED] wrote:
 On Feb 2, 2008 2:19 PM, Igor Vaynberg [EMAIL PROTECTED] wrote:
  well, thats the problem. you say you are not the right person because
  you dont know. and that is the excuse a lot of users give for not
  writing the wiki page. but guess what, after we help them here and
  they do understand how listview works - they still dont come back and
  write the wiki page.

 Don't be too harsh. There have been quite a few people who wrote for
 the WIKI before, and to be honest, I haven't always shared my
 experiences with e.g. Hibernate with the rest of the world either.

 How about a reconsideration of depreciating ListView?

 Eelco


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to delete an item from List view.

2008-02-01 Thread pnerkar

Hi Eelco,

RefreshingView is available in wicket 1.3.0.
While I'm using wicket 1.2.6.

Regards,

Pankaj,...


Eelco Hillenius wrote:
 
 On Jan 31, 2008 3:49 PM, pnerkar [EMAIL PROTECTED] wrote:

 Hi All,

 I have rendered a list view on a Web Page.

 vehicle1X
 vehicle2X
 vehicle3X

 when a person click on 'X', that item should be deleted.
 But I'm facing an issue, when i click on 'X', last item get deleted.
 Actually when I delete vehicle2 from my list, it deletes vehicle2 but
 that
 component is still there.
 So while rendering it render vehicle1  vehicle2.

 public void onSubmit() {
 List vehicles = (List) getParent().getParent().getModelObject();
 vehicles.remove(index);
 }
 
 Instead of using ListView, you could consider RefreshingView with it's
 itemReuseStrategy set to ReuseIfModelsEqualStrategy.
 
 Eelco
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/How-to-delete-an-item-from-List-view.-tp15217608p15227738.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to delete an item from List view.

2008-02-01 Thread Martijn Dashorst
see wicket-extensions
Martijn

On 2/1/08, pnerkar [EMAIL PROTECTED] wrote:


 Hi Eelco,

 RefreshingView is available in wicket 1.3.0.
 While I'm using wicket 1.2.6.

 Regards,

 Pankaj,...


 Eelco Hillenius wrote:
 
  On Jan 31, 2008 3:49 PM, pnerkar [EMAIL PROTECTED] wrote:
 
  Hi All,
 
  I have rendered a list view on a Web Page.
 
  vehicle1X
  vehicle2X
  vehicle3X
 
  when a person click on 'X', that item should be deleted.
  But I'm facing an issue, when i click on 'X', last item get deleted.
  Actually when I delete vehicle2 from my list, it deletes vehicle2 but
  that
  component is still there.
  So while rendering it render vehicle1  vehicle2.
 
  public void onSubmit() {
  List vehicles = (List)
 getParent().getParent().getModelObject();
  vehicles.remove(index);
  }
 
  Instead of using ListView, you could consider RefreshingView with it's
  itemReuseStrategy set to ReuseIfModelsEqualStrategy.
 
  Eelco
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

 --
 View this message in context:
 http://www.nabble.com/How-to-delete-an-item-from-List-view.-tp15217608p15227738.html
 Sent from the Wicket - User mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




-- 
Buy Wicket in Action: http://manning.com/dashorst
Apache Wicket 1.3.0 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.0


Re: How to delete an item from List view.

2008-02-01 Thread pnerkar

Hi Igor,

Finally I'm able to find out the exact issue.
suppose There are 3 items in the list-
wicket will assign id as 0, 1  2. to those items.
So When we say  item.getparent().remove(item) to item with id=1,
them It'll remove that item from list but item with id=2 will not remain as
it is..
i.e.  Now list will have 2 items one with id=0  id=2.
So when we display list, it'll clears the fields for item with id=1.
so we need to update id field of item object... But think there is no way to
do that...

is there...???

-Pnerkar



igor.vaynberg wrote:
 
 try this:
 
 onpopulate (final listitem item) {
add(new link(remove) { onclick() { 
 item.getparent().remove(item); }}
 }
 
 -igor
 
 
 On Jan 31, 2008 6:19 PM, pnerkar [EMAIL PROTECTED] wrote:

 Hi igor,

 But If I remove setReuseItems(true), it'll remove all field values which
 user has entered will be removed.
 Bcz default processing  is false for Remove button (Sorry forget to tell
 you)
 I just want to remove vehicle2, but the values entered for vehicle1 
 vehicle3 should not be lost.


 - Pnerkar





 igor.vaynberg wrote:
 
  vehicles.setReuseItems(true); == that is what is causing your list to
  reuse old components
 
  -igor
 
 
  On Jan 31, 2008 5:36 PM, pnerkar [EMAIL PROTECTED] wrote:
 
  Hi,
 
  Following is my code for rendering vehicle list-
 
  final VehiclesList vehicles = new VehiclesList(vehicledetails,
  ((RatingRequestAuto)getModelObject()).getVehicles());
  vehicles.setOutputMarkupId(true);
  vehicles.setReuseItems(true);
  add(vehicles);
 
  private static class VehiclesList extends ListView {
 
 
  public VehiclesList (String id, List vehicles) {
  super (id, vehicles);
 
  }
 
  protected void populateItem(final ListItem item)
  {
 
  item.add(new TextField(vehicle.modelText, new
  PropertyModel(vehicle, model)).setRequired(true));
  TextField registrationnumber = new
  TextField(vehicle.registrationnumber, new PropertyModel(vehicle,
  registrationNumber));
  TextField engineNumber = new
  TextField(vehicle.enginenumber, new
  PropertyModel(vehicle, engineNumber));
 
  final int index = item.getIndex();
  Button remVehBtn = new Button(btn_removeVeh,
  new ResourceModel(
  removevehicle )) {
  public void onSubmit() {
  List vehicles = (List)
  getParent().getParent().getModelObject();
  vehicles.remove(index);
  }
  });
  }
  }
 
  Thanks a lot for ur reply :)
 
 
 
 
  igor.vaynberg wrote:
  
   show us how you populate your listview...
  
   -igor
  
  
   On Jan 31, 2008 3:49 PM, pnerkar [EMAIL PROTECTED] wrote:
  
   Hi All,
  
   I have rendered a list view on a Web Page.
  
   vehicle1X
   vehicle2X
   vehicle3X
  
   when a person click on 'X', that item should be deleted.
   But I'm facing an issue, when i click on 'X', last item get
 deleted.
   Actually when I delete vehicle2 from my list, it deletes vehicle2
 but
   that
   component is still there.
   So while rendering it render vehicle1  vehicle2.
  
   public void onSubmit() {
   List vehicles = (List)
  getParent().getParent().getModelObject();
   vehicles.remove(index);
   }
  
   can please help out ??
  
  
  
   --
   View this message in context:
  
 
 http://www.nabble.com/How-to-delete-an-item-from-List-view.-tp15217608p15217608.html
   Sent from the Wicket - User mailing list archive at Nabble.com.
  
  
  
 -
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  
  
  
 -
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  
  
 
  --
  View this message in context:
 
 http://www.nabble.com/How-to-delete-an-item-from-List-view.-tp15217608p15218960.html
 
  Sent from the Wicket - User mailing list archive at Nabble.com.
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

 --
 View this message in context:
 http://www.nabble.com/How-to-delete-an-item-from-List-view.-tp15217608p15219402.html

 Sent from the Wicket - User mailing list archive at Nabble.com.


 -
 To unsubscribe, 

Re: How to delete an item from List view.

2008-02-01 Thread Igor Vaynberg
dont use a listview, use a refreshingview and provide an itemreuse strategy.

-igor


On Feb 1, 2008 1:51 PM, pnerkar [EMAIL PROTECTED] wrote:

 Hi Igor,

 Finally I'm able to find out the exact issue.
 suppose There are 3 items in the list-
 wicket will assign id as 0, 1  2. to those items.
 So When we say  item.getparent().remove(item) to item with id=1,
 them It'll remove that item from list but item with id=2 will not remain as
 it is..
 i.e.  Now list will have 2 items one with id=0  id=2.
 So when we display list, it'll clears the fields for item with id=1.
 so we need to update id field of item object... But think there is no way to
 do that...

 is there...???

 -Pnerkar




 igor.vaynberg wrote:
 
  try this:
 
  onpopulate (final listitem item) {
 add(new link(remove) { onclick() { 
  item.getparent().remove(item); }}
  }
 
  -igor
 
 
  On Jan 31, 2008 6:19 PM, pnerkar [EMAIL PROTECTED] wrote:
 
  Hi igor,
 
  But If I remove setReuseItems(true), it'll remove all field values which
  user has entered will be removed.
  Bcz default processing  is false for Remove button (Sorry forget to tell
  you)
  I just want to remove vehicle2, but the values entered for vehicle1 
  vehicle3 should not be lost.
 
 
  - Pnerkar
 
 
 
 
 
  igor.vaynberg wrote:
  
   vehicles.setReuseItems(true); == that is what is causing your list to
   reuse old components
  
   -igor
  
  
   On Jan 31, 2008 5:36 PM, pnerkar [EMAIL PROTECTED] wrote:
  
   Hi,
  
   Following is my code for rendering vehicle list-
  
   final VehiclesList vehicles = new VehiclesList(vehicledetails,
   ((RatingRequestAuto)getModelObject()).getVehicles());
   vehicles.setOutputMarkupId(true);
   vehicles.setReuseItems(true);
   add(vehicles);
  
   private static class VehiclesList extends ListView {
  
  
   public VehiclesList (String id, List vehicles) {
   super (id, vehicles);
  
   }
  
   protected void populateItem(final ListItem item)
   {
  
   item.add(new TextField(vehicle.modelText, new
   PropertyModel(vehicle, model)).setRequired(true));
   TextField registrationnumber = new
   TextField(vehicle.registrationnumber, new PropertyModel(vehicle,
   registrationNumber));
   TextField engineNumber = new
   TextField(vehicle.enginenumber, new
   PropertyModel(vehicle, engineNumber));
  
   final int index = item.getIndex();
   Button remVehBtn = new Button(btn_removeVeh,
   new ResourceModel(
   removevehicle )) {
   public void onSubmit() {
   List vehicles = (List)
   getParent().getParent().getModelObject();
   vehicles.remove(index);
   }
   });
   }
   }
  
   Thanks a lot for ur reply :)
  
  
  
  
   igor.vaynberg wrote:
   
show us how you populate your listview...
   
-igor
   
   
On Jan 31, 2008 3:49 PM, pnerkar [EMAIL PROTECTED] wrote:
   
Hi All,
   
I have rendered a list view on a Web Page.
   
vehicle1X
vehicle2X
vehicle3X
   
when a person click on 'X', that item should be deleted.
But I'm facing an issue, when i click on 'X', last item get
  deleted.
Actually when I delete vehicle2 from my list, it deletes vehicle2
  but
that
component is still there.
So while rendering it render vehicle1  vehicle2.
   
public void onSubmit() {
List vehicles = (List)
   getParent().getParent().getModelObject();
vehicles.remove(index);
}
   
can please help out ??
   
   
   
--
View this message in context:
   
  
  http://www.nabble.com/How-to-delete-an-item-from-List-view.-tp15217608p15217608.html
Sent from the Wicket - User mailing list archive at Nabble.com.
   
   
   
  -
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
   
   
   
   
  -
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
   
   
   
  
   --
   View this message in context:
  
  http://www.nabble.com/How-to-delete-an-item-from-List-view.-tp15217608p15218960.html
  
   Sent from the Wicket - User mailing list archive at Nabble.com.
  
  
   -
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  
  
   -
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional 

Re: How to delete an item from List view.

2008-02-01 Thread pnerkar

Ya I tried refreshingview with ReuseIfModelsEqualStrategy, 
But the data entered on page get cleared.

My new code is -


final VehiclesList vehicles = new VehiclesList(vehicles, new
PropertyModel((RatingRequestAuto)getModelObject(),vehicles));
vehicles.setOutputMarkupId(true);
vehicles.setItemReuseStrategy(new ReuseIfModelsEqualStrategy());
add(vehicles);

private static class VehiclesList extends RefreshingView {


public VehiclesList (String id, PropertyModel model) {
super (id,model);
}

  /**
 * Return an iterator over models for items in the view
 */
protected Iterator getItemModels()
{
List models = new ArrayList();
for(int i=0;i((List)getModelObject()).size();i++){
models.add(new Model( (Vehicle) 
((List)getModelObject()).get(i)));
}
return models.iterator();
}

protected void populateItem(final ListItem item)
 {

item.add(new TextField(vehicle.modelText, new
PropertyModel(vehicle, model)).setRequired(true));
TextField registrationnumber = new
TextField(vehicle.registrationnumber, new PropertyModel(vehicle,
registrationNumber));
TextField engineNumber = new 
TextField(vehicle.enginenumber, new
PropertyModel(vehicle, engineNumber));

final int index = item.getIndex();
Button remVehBtn = new Button(btn_removeVeh, 
new ResourceModel(
removevehicle )) {
public void onSubmit() {

item.getParent().remove(item);
}
});
}
} 
}

forgive me this may not be a cleaner way... I dont have more than a month
exp of wicket.

-pnerkar



igor.vaynberg wrote:
 
 dont use a listview, use a refreshingview and provide an itemreuse
 strategy.
 
 -igor
 
 
 On Feb 1, 2008 1:51 PM, pnerkar [EMAIL PROTECTED] wrote:

 Hi Igor,

 Finally I'm able to find out the exact issue.
 suppose There are 3 items in the list-
 wicket will assign id as 0, 1  2. to those items.
 So When we say  item.getparent().remove(item) to item with id=1,
 them It'll remove that item from list but item with id=2 will not remain
 as
 it is..
 i.e.  Now list will have 2 items one with id=0  id=2.
 So when we display list, it'll clears the fields for item with id=1.
 so we need to update id field of item object... But think there is no way
 to
 do that...

 is there...???

 -Pnerkar




 igor.vaynberg wrote:
 
  try this:
 
  onpopulate (final listitem item) {
 add(new link(remove) { onclick() { 
  item.getparent().remove(item); }}
  }
 
  -igor
 
 
  On Jan 31, 2008 6:19 PM, pnerkar [EMAIL PROTECTED] wrote:
 
  Hi igor,
 
  But If I remove setReuseItems(true), it'll remove all field values
 which
  user has entered will be removed.
  Bcz default processing  is false for Remove button (Sorry forget to
 tell
  you)
  I just want to remove vehicle2, but the values entered for vehicle1 
  vehicle3 should not be lost.
 
 
  - Pnerkar
 
 
 
 
 
  igor.vaynberg wrote:
  
   vehicles.setReuseItems(true); == that is what is causing your list
 to
   reuse old components
  
   -igor
  
  
   On Jan 31, 2008 5:36 PM, pnerkar [EMAIL PROTECTED] wrote:
  
   Hi,
  
   Following is my code for rendering vehicle list-
  
   final VehiclesList vehicles = new VehiclesList(vehicledetails,
   ((RatingRequestAuto)getModelObject()).getVehicles());
   vehicles.setOutputMarkupId(true);
   vehicles.setReuseItems(true);
   add(vehicles);
  
   private static class VehiclesList extends ListView {
  
  
   public VehiclesList (String id, List vehicles) {
   super (id, vehicles);
  
   }
  
   protected void populateItem(final ListItem item)
   {
  
   item.add(new TextField(vehicle.modelText, new
   PropertyModel(vehicle, model)).setRequired(true));
   TextField registrationnumber = new
   TextField(vehicle.registrationnumber, new PropertyModel(vehicle,
   registrationNumber));
   TextField engineNumber = new
   TextField(vehicle.enginenumber, new
   PropertyModel(vehicle, engineNumber));
  
   final int index = item.getIndex();
   Button remVehBtn = new
 Button(btn_removeVeh,
   new ResourceModel(
   removevehicle )) {
   public void onSubmit() {
   

Re: How to delete an item from List view.

2008-02-01 Thread Igor Vaynberg
for the strategy to work properly you have to implement
equals/hashcode on the model, looks like you are just doing:

new Model( (Vehicle) ((List)getModelObject()).get(i))

Model does not implement equals/hashcode

-igor


On Feb 1, 2008 4:03 PM, pnerkar [EMAIL PROTECTED] wrote:

 Ya I tried refreshingview with ReuseIfModelsEqualStrategy,
 But the data entered on page get cleared.

 My new code is -


 final VehiclesList vehicles = new VehiclesList(vehicles, new
 PropertyModel((RatingRequestAuto)getModelObject(),vehicles));
 vehicles.setOutputMarkupId(true);
 vehicles.setItemReuseStrategy(new ReuseIfModelsEqualStrategy());
 add(vehicles);

 private static class VehiclesList extends RefreshingView {


 public VehiclesList (String id, PropertyModel model) {
 super (id,model);
 }

   /**
  * Return an iterator over models for items in the view
  */
 protected Iterator getItemModels()
 {
 List models = new ArrayList();
 for(int i=0;i((List)getModelObject()).size();i++){
 models.add(new Model( (Vehicle) 
 ((List)getModelObject()).get(i)));
 }
 return models.iterator();
 }

 protected void populateItem(final ListItem item)
  {

 item.add(new TextField(vehicle.modelText, new
 PropertyModel(vehicle, model)).setRequired(true));
 TextField registrationnumber = new
 TextField(vehicle.registrationnumber, new PropertyModel(vehicle,
 registrationNumber));
 TextField engineNumber = new 
 TextField(vehicle.enginenumber, new
 PropertyModel(vehicle, engineNumber));

 final int index = item.getIndex();
 Button remVehBtn = new 
 Button(btn_removeVeh, new ResourceModel(
 removevehicle )) {
 public void onSubmit() {
 
 item.getParent().remove(item);
 }
 });
 }
 }
 }

 forgive me this may not be a cleaner way... I dont have more than a month
 exp of wicket.

 -pnerkar




 igor.vaynberg wrote:
 
  dont use a listview, use a refreshingview and provide an itemreuse
  strategy.
 
  -igor
 
 
  On Feb 1, 2008 1:51 PM, pnerkar [EMAIL PROTECTED] wrote:
 
  Hi Igor,
 
  Finally I'm able to find out the exact issue.
  suppose There are 3 items in the list-
  wicket will assign id as 0, 1  2. to those items.
  So When we say  item.getparent().remove(item) to item with id=1,
  them It'll remove that item from list but item with id=2 will not remain
  as
  it is..
  i.e.  Now list will have 2 items one with id=0  id=2.
  So when we display list, it'll clears the fields for item with id=1.
  so we need to update id field of item object... But think there is no way
  to
  do that...
 
  is there...???
 
  -Pnerkar
 
 
 
 
  igor.vaynberg wrote:
  
   try this:
  
   onpopulate (final listitem item) {
  add(new link(remove) { onclick() { 
   item.getparent().remove(item); }}
   }
  
   -igor
  
  
   On Jan 31, 2008 6:19 PM, pnerkar [EMAIL PROTECTED] wrote:
  
   Hi igor,
  
   But If I remove setReuseItems(true), it'll remove all field values
  which
   user has entered will be removed.
   Bcz default processing  is false for Remove button (Sorry forget to
  tell
   you)
   I just want to remove vehicle2, but the values entered for vehicle1 
   vehicle3 should not be lost.
  
  
   - Pnerkar
  
  
  
  
  
   igor.vaynberg wrote:
   
vehicles.setReuseItems(true); == that is what is causing your list
  to
reuse old components
   
-igor
   
   
On Jan 31, 2008 5:36 PM, pnerkar [EMAIL PROTECTED] wrote:
   
Hi,
   
Following is my code for rendering vehicle list-
   
final VehiclesList vehicles = new VehiclesList(vehicledetails,
((RatingRequestAuto)getModelObject()).getVehicles());
vehicles.setOutputMarkupId(true);
vehicles.setReuseItems(true);
add(vehicles);
   
private static class VehiclesList extends ListView {
   
   
public VehiclesList (String id, List vehicles) {
super (id, vehicles);
   
}
   
protected void populateItem(final ListItem item)
{
   
item.add(new TextField(vehicle.modelText, new
PropertyModel(vehicle, model)).setRequired(true));
TextField registrationnumber = new
TextField(vehicle.registrationnumber, new PropertyModel(vehicle,
registrationNumber));
 

Re: How to delete an item from List view.

2008-02-01 Thread pnerkar

Hi igor,

Ya I read this from one of ur doc. 
http://www.wicketframework.org/wicket-extensions/apidocs/wicket/extensions/markup/html/repeater/refreshing/ReuseIfModelsEqualStrategy.html
I have implemented equals/hashcode in Vehicle object.

-pnerkar


igor.vaynberg wrote:
 
 for the strategy to work properly you have to implement
 equals/hashcode on the model, looks like you are just doing:
 
 new Model( (Vehicle) ((List)getModelObject()).get(i))
 
 Model does not implement equals/hashcode
 
 -igor
 
 
 On Feb 1, 2008 4:03 PM, pnerkar [EMAIL PROTECTED] wrote:

 Ya I tried refreshingview with ReuseIfModelsEqualStrategy,
 But the data entered on page get cleared.

 My new code is -


 final VehiclesList vehicles = new VehiclesList(vehicles, new
 PropertyModel((RatingRequestAuto)getModelObject(),vehicles));
 vehicles.setOutputMarkupId(true);
 vehicles.setItemReuseStrategy(new ReuseIfModelsEqualStrategy());
 add(vehicles);

 private static class VehiclesList extends RefreshingView {


 public VehiclesList (String id, PropertyModel model) {
 super (id,model);
 }

   /**
  * Return an iterator over models for items in the view
  */
 protected Iterator getItemModels()
 {
 List models = new ArrayList();
 for(int
 i=0;i((List)getModelObject()).size();i++){
 models.add(new Model( (Vehicle)
 ((List)getModelObject()).get(i)));
 }
 return models.iterator();
 }

 protected void populateItem(final ListItem item)
  {

 item.add(new TextField(vehicle.modelText, new
 PropertyModel(vehicle, model)).setRequired(true));
 TextField registrationnumber = new
 TextField(vehicle.registrationnumber, new PropertyModel(vehicle,
 registrationNumber));
 TextField engineNumber = new
 TextField(vehicle.enginenumber, new
 PropertyModel(vehicle, engineNumber));

 final int index = item.getIndex();
 Button remVehBtn = new
 Button(btn_removeVeh, new ResourceModel(
 removevehicle )) {
 public void onSubmit() {

 item.getParent().remove(item);
 }
 });
 }
 }
 }

 forgive me this may not be a cleaner way... I dont have more than a month
 exp of wicket.

 -pnerkar




 igor.vaynberg wrote:
 
  dont use a listview, use a refreshingview and provide an itemreuse
  strategy.
 
  -igor
 
 
  On Feb 1, 2008 1:51 PM, pnerkar [EMAIL PROTECTED] wrote:
 
  Hi Igor,
 
  Finally I'm able to find out the exact issue.
  suppose There are 3 items in the list-
  wicket will assign id as 0, 1  2. to those items.
  So When we say  item.getparent().remove(item) to item with id=1,
  them It'll remove that item from list but item with id=2 will not
 remain
  as
  it is..
  i.e.  Now list will have 2 items one with id=0  id=2.
  So when we display list, it'll clears the fields for item with id=1.
  so we need to update id field of item object... But think there is no
 way
  to
  do that...
 
  is there...???
 
  -Pnerkar
 
 
 
 
  igor.vaynberg wrote:
  
   try this:
  
   onpopulate (final listitem item) {
  add(new link(remove) { onclick() { 
   item.getparent().remove(item); }}
   }
  
   -igor
  
  
   On Jan 31, 2008 6:19 PM, pnerkar [EMAIL PROTECTED] wrote:
  
   Hi igor,
  
   But If I remove setReuseItems(true), it'll remove all field values
  which
   user has entered will be removed.
   Bcz default processing  is false for Remove button (Sorry forget to
  tell
   you)
   I just want to remove vehicle2, but the values entered for vehicle1
 
   vehicle3 should not be lost.
  
  
   - Pnerkar
  
  
  
  
  
   igor.vaynberg wrote:
   
vehicles.setReuseItems(true); == that is what is causing your
 list
  to
reuse old components
   
-igor
   
   
On Jan 31, 2008 5:36 PM, pnerkar [EMAIL PROTECTED] wrote:
   
Hi,
   
Following is my code for rendering vehicle list-
   
final VehiclesList vehicles = new VehiclesList(vehicledetails,
((RatingRequestAuto)getModelObject()).getVehicles());
vehicles.setOutputMarkupId(true);
vehicles.setReuseItems(true);
add(vehicles);
   
private static class VehiclesList extends ListView {
   
   
public VehiclesList (String id, List vehicles) {
super (id, vehicles);
   
}
   
protected void populateItem(final ListItem item)
   

Re: How to delete an item from List view.

2008-02-01 Thread Igor Vaynberg
read the notice part of the javadoc...

-igor


On Feb 1, 2008 5:49 PM, pnerkar [EMAIL PROTECTED] wrote:

 Hi igor,

 Ya I read this from one of ur doc.
 http://www.wicketframework.org/wicket-extensions/apidocs/wicket/extensions/markup/html/repeater/refreshing/ReuseIfModelsEqualStrategy.html
 I have implemented equals/hashcode in Vehicle object.

 -pnerkar



 igor.vaynberg wrote:
 
  for the strategy to work properly you have to implement
  equals/hashcode on the model, looks like you are just doing:
 
  new Model( (Vehicle) ((List)getModelObject()).get(i))
 
  Model does not implement equals/hashcode
 
  -igor
 
 
  On Feb 1, 2008 4:03 PM, pnerkar [EMAIL PROTECTED] wrote:
 
  Ya I tried refreshingview with ReuseIfModelsEqualStrategy,
  But the data entered on page get cleared.
 
  My new code is -
 
 
  final VehiclesList vehicles = new VehiclesList(vehicles, new
  PropertyModel((RatingRequestAuto)getModelObject(),vehicles));
  vehicles.setOutputMarkupId(true);
  vehicles.setItemReuseStrategy(new ReuseIfModelsEqualStrategy());
  add(vehicles);
 
  private static class VehiclesList extends RefreshingView {
 
 
  public VehiclesList (String id, PropertyModel model) {
  super (id,model);
  }
 
/**
   * Return an iterator over models for items in the view
   */
  protected Iterator getItemModels()
  {
  List models = new ArrayList();
  for(int
  i=0;i((List)getModelObject()).size();i++){
  models.add(new Model( (Vehicle)
  ((List)getModelObject()).get(i)));
  }
  return models.iterator();
  }
 
  protected void populateItem(final ListItem item)
   {
 
  item.add(new TextField(vehicle.modelText, new
  PropertyModel(vehicle, model)).setRequired(true));
  TextField registrationnumber = new
  TextField(vehicle.registrationnumber, new PropertyModel(vehicle,
  registrationNumber));
  TextField engineNumber = new
  TextField(vehicle.enginenumber, new
  PropertyModel(vehicle, engineNumber));
 
  final int index = item.getIndex();
  Button remVehBtn = new
  Button(btn_removeVeh, new ResourceModel(
  removevehicle )) {
  public void onSubmit() {
 
  item.getParent().remove(item);
  }
  });
  }
  }
  }
 
  forgive me this may not be a cleaner way... I dont have more than a month
  exp of wicket.
 
  -pnerkar
 
 
 
 
  igor.vaynberg wrote:
  
   dont use a listview, use a refreshingview and provide an itemreuse
   strategy.
  
   -igor
  
  
   On Feb 1, 2008 1:51 PM, pnerkar [EMAIL PROTECTED] wrote:
  
   Hi Igor,
  
   Finally I'm able to find out the exact issue.
   suppose There are 3 items in the list-
   wicket will assign id as 0, 1  2. to those items.
   So When we say  item.getparent().remove(item) to item with id=1,
   them It'll remove that item from list but item with id=2 will not
  remain
   as
   it is..
   i.e.  Now list will have 2 items one with id=0  id=2.
   So when we display list, it'll clears the fields for item with id=1.
   so we need to update id field of item object... But think there is no
  way
   to
   do that...
  
   is there...???
  
   -Pnerkar
  
  
  
  
   igor.vaynberg wrote:
   
try this:
   
onpopulate (final listitem item) {
   add(new link(remove) { onclick() { 
item.getparent().remove(item); }}
}
   
-igor
   
   
On Jan 31, 2008 6:19 PM, pnerkar [EMAIL PROTECTED] wrote:
   
Hi igor,
   
But If I remove setReuseItems(true), it'll remove all field values
   which
user has entered will be removed.
Bcz default processing  is false for Remove button (Sorry forget to
   tell
you)
I just want to remove vehicle2, but the values entered for vehicle1
  
vehicle3 should not be lost.
   
   
- Pnerkar
   
   
   
   
   
igor.vaynberg wrote:

 vehicles.setReuseItems(true); == that is what is causing your
  list
   to
 reuse old components

 -igor


 On Jan 31, 2008 5:36 PM, pnerkar [EMAIL PROTECTED] wrote:

 Hi,

 Following is my code for rendering vehicle list-

 final VehiclesList vehicles = new VehiclesList(vehicledetails,
 ((RatingRequestAuto)getModelObject()).getVehicles());
 vehicles.setOutputMarkupId(true);
 vehicles.setReuseItems(true);
 add(vehicles);

 private static class VehiclesList extends ListView {


 

Re: How to delete an item from List view.

2008-01-31 Thread Igor Vaynberg
show us how you populate your listview...

-igor


On Jan 31, 2008 3:49 PM, pnerkar [EMAIL PROTECTED] wrote:

 Hi All,

 I have rendered a list view on a Web Page.

 vehicle1X
 vehicle2X
 vehicle3X

 when a person click on 'X', that item should be deleted.
 But I'm facing an issue, when i click on 'X', last item get deleted.
 Actually when I delete vehicle2 from my list, it deletes vehicle2 but that
 component is still there.
 So while rendering it render vehicle1  vehicle2.

 public void onSubmit() {
 List vehicles = (List) getParent().getParent().getModelObject();
 vehicles.remove(index);
 }

 can please help out ??



 --
 View this message in context: 
 http://www.nabble.com/How-to-delete-an-item-from-List-view.-tp15217608p15217608.html
 Sent from the Wicket - User mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to delete an item from List view.

2008-01-31 Thread pnerkar

Hi,

Following is my code for rendering vehicle list-

final VehiclesList vehicles = new VehiclesList(vehicledetails,
((RatingRequestAuto)getModelObject()).getVehicles());
vehicles.setOutputMarkupId(true);
vehicles.setReuseItems(true);
add(vehicles);

private static class VehiclesList extends ListView {


public VehiclesList (String id, List vehicles) {
super (id, vehicles);

}

protected void populateItem(final ListItem item)
{

item.add(new TextField(vehicle.modelText, new
PropertyModel(vehicle, model)).setRequired(true));
TextField registrationnumber = new
TextField(vehicle.registrationnumber, new PropertyModel(vehicle,
registrationNumber));
TextField engineNumber = new 
TextField(vehicle.enginenumber, new
PropertyModel(vehicle, engineNumber));

final int index = item.getIndex();
Button remVehBtn = new Button(btn_removeVeh, new 
ResourceModel(
removevehicle )) {
public void onSubmit() {
List vehicles = (List) 
getParent().getParent().getModelObject();
vehicles.remove(index);
}
});
}
}

Thanks a lot for ur reply :)



igor.vaynberg wrote:
 
 show us how you populate your listview...
 
 -igor
 
 
 On Jan 31, 2008 3:49 PM, pnerkar [EMAIL PROTECTED] wrote:

 Hi All,

 I have rendered a list view on a Web Page.

 vehicle1X
 vehicle2X
 vehicle3X

 when a person click on 'X', that item should be deleted.
 But I'm facing an issue, when i click on 'X', last item get deleted.
 Actually when I delete vehicle2 from my list, it deletes vehicle2 but
 that
 component is still there.
 So while rendering it render vehicle1  vehicle2.

 public void onSubmit() {
 List vehicles = (List) getParent().getParent().getModelObject();
 vehicles.remove(index);
 }

 can please help out ??



 --
 View this message in context:
 http://www.nabble.com/How-to-delete-an-item-from-List-view.-tp15217608p15217608.html
 Sent from the Wicket - User mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]


 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/How-to-delete-an-item-from-List-view.-tp15217608p15218960.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to delete an item from List view.

2008-01-31 Thread Igor Vaynberg
vehicles.setReuseItems(true); == that is what is causing your list to
reuse old components

-igor


On Jan 31, 2008 5:36 PM, pnerkar [EMAIL PROTECTED] wrote:

 Hi,

 Following is my code for rendering vehicle list-

 final VehiclesList vehicles = new VehiclesList(vehicledetails,
 ((RatingRequestAuto)getModelObject()).getVehicles());
 vehicles.setOutputMarkupId(true);
 vehicles.setReuseItems(true);
 add(vehicles);

 private static class VehiclesList extends ListView {


 public VehiclesList (String id, List vehicles) {
 super (id, vehicles);

 }

 protected void populateItem(final ListItem item)
 {

 item.add(new TextField(vehicle.modelText, new
 PropertyModel(vehicle, model)).setRequired(true));
 TextField registrationnumber = new
 TextField(vehicle.registrationnumber, new PropertyModel(vehicle,
 registrationNumber));
 TextField engineNumber = new 
 TextField(vehicle.enginenumber, new
 PropertyModel(vehicle, engineNumber));

 final int index = item.getIndex();
 Button remVehBtn = new Button(btn_removeVeh, new 
 ResourceModel(
 removevehicle )) {
 public void onSubmit() {
 List vehicles = (List) 
 getParent().getParent().getModelObject();
 vehicles.remove(index);
 }
 });
 }
 }

 Thanks a lot for ur reply :)




 igor.vaynberg wrote:
 
  show us how you populate your listview...
 
  -igor
 
 
  On Jan 31, 2008 3:49 PM, pnerkar [EMAIL PROTECTED] wrote:
 
  Hi All,
 
  I have rendered a list view on a Web Page.
 
  vehicle1X
  vehicle2X
  vehicle3X
 
  when a person click on 'X', that item should be deleted.
  But I'm facing an issue, when i click on 'X', last item get deleted.
  Actually when I delete vehicle2 from my list, it deletes vehicle2 but
  that
  component is still there.
  So while rendering it render vehicle1  vehicle2.
 
  public void onSubmit() {
  List vehicles = (List) getParent().getParent().getModelObject();
  vehicles.remove(index);
  }
 
  can please help out ??
 
 
 
  --
  View this message in context:
  http://www.nabble.com/How-to-delete-an-item-from-List-view.-tp15217608p15217608.html
  Sent from the Wicket - User mailing list archive at Nabble.com.
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

 --
 View this message in context: 
 http://www.nabble.com/How-to-delete-an-item-from-List-view.-tp15217608p15218960.html

 Sent from the Wicket - User mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to delete an item from List view.

2008-01-31 Thread pnerkar

Hi igor,

But If I remove setReuseItems(true), it'll remove all field values which
user has entered will be removed.
Bcz default processing  is false for Remove button (Sorry forget to tell
you)
I just want to remove vehicle2, but the values entered for vehicle1 
vehicle3 should not be lost.


- Pnerkar




igor.vaynberg wrote:
 
 vehicles.setReuseItems(true); == that is what is causing your list to
 reuse old components
 
 -igor
 
 
 On Jan 31, 2008 5:36 PM, pnerkar [EMAIL PROTECTED] wrote:

 Hi,

 Following is my code for rendering vehicle list-

 final VehiclesList vehicles = new VehiclesList(vehicledetails,
 ((RatingRequestAuto)getModelObject()).getVehicles());
 vehicles.setOutputMarkupId(true);
 vehicles.setReuseItems(true);
 add(vehicles);

 private static class VehiclesList extends ListView {


 public VehiclesList (String id, List vehicles) {
 super (id, vehicles);

 }

 protected void populateItem(final ListItem item)
 {

 item.add(new TextField(vehicle.modelText, new
 PropertyModel(vehicle, model)).setRequired(true));
 TextField registrationnumber = new
 TextField(vehicle.registrationnumber, new PropertyModel(vehicle,
 registrationNumber));
 TextField engineNumber = new
 TextField(vehicle.enginenumber, new
 PropertyModel(vehicle, engineNumber));

 final int index = item.getIndex();
 Button remVehBtn = new Button(btn_removeVeh,
 new ResourceModel(
 removevehicle )) {
 public void onSubmit() {
 List vehicles = (List)
 getParent().getParent().getModelObject();
 vehicles.remove(index);
 }
 });
 }
 }

 Thanks a lot for ur reply :)




 igor.vaynberg wrote:
 
  show us how you populate your listview...
 
  -igor
 
 
  On Jan 31, 2008 3:49 PM, pnerkar [EMAIL PROTECTED] wrote:
 
  Hi All,
 
  I have rendered a list view on a Web Page.
 
  vehicle1X
  vehicle2X
  vehicle3X
 
  when a person click on 'X', that item should be deleted.
  But I'm facing an issue, when i click on 'X', last item get deleted.
  Actually when I delete vehicle2 from my list, it deletes vehicle2 but
  that
  component is still there.
  So while rendering it render vehicle1  vehicle2.
 
  public void onSubmit() {
  List vehicles = (List)
 getParent().getParent().getModelObject();
  vehicles.remove(index);
  }
 
  can please help out ??
 
 
 
  --
  View this message in context:
 
 http://www.nabble.com/How-to-delete-an-item-from-List-view.-tp15217608p15217608.html
  Sent from the Wicket - User mailing list archive at Nabble.com.
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

 --
 View this message in context:
 http://www.nabble.com/How-to-delete-an-item-from-List-view.-tp15217608p15218960.html

 Sent from the Wicket - User mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]


 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/How-to-delete-an-item-from-List-view.-tp15217608p15219402.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to delete an item from List view.

2008-01-31 Thread Igor Vaynberg
try this:

onpopulate (final listitem item) {
   add(new link(remove) { onclick() {  item.getparent().remove(item); }}
}

-igor


On Jan 31, 2008 6:19 PM, pnerkar [EMAIL PROTECTED] wrote:

 Hi igor,

 But If I remove setReuseItems(true), it'll remove all field values which
 user has entered will be removed.
 Bcz default processing  is false for Remove button (Sorry forget to tell
 you)
 I just want to remove vehicle2, but the values entered for vehicle1 
 vehicle3 should not be lost.


 - Pnerkar





 igor.vaynberg wrote:
 
  vehicles.setReuseItems(true); == that is what is causing your list to
  reuse old components
 
  -igor
 
 
  On Jan 31, 2008 5:36 PM, pnerkar [EMAIL PROTECTED] wrote:
 
  Hi,
 
  Following is my code for rendering vehicle list-
 
  final VehiclesList vehicles = new VehiclesList(vehicledetails,
  ((RatingRequestAuto)getModelObject()).getVehicles());
  vehicles.setOutputMarkupId(true);
  vehicles.setReuseItems(true);
  add(vehicles);
 
  private static class VehiclesList extends ListView {
 
 
  public VehiclesList (String id, List vehicles) {
  super (id, vehicles);
 
  }
 
  protected void populateItem(final ListItem item)
  {
 
  item.add(new TextField(vehicle.modelText, new
  PropertyModel(vehicle, model)).setRequired(true));
  TextField registrationnumber = new
  TextField(vehicle.registrationnumber, new PropertyModel(vehicle,
  registrationNumber));
  TextField engineNumber = new
  TextField(vehicle.enginenumber, new
  PropertyModel(vehicle, engineNumber));
 
  final int index = item.getIndex();
  Button remVehBtn = new Button(btn_removeVeh,
  new ResourceModel(
  removevehicle )) {
  public void onSubmit() {
  List vehicles = (List)
  getParent().getParent().getModelObject();
  vehicles.remove(index);
  }
  });
  }
  }
 
  Thanks a lot for ur reply :)
 
 
 
 
  igor.vaynberg wrote:
  
   show us how you populate your listview...
  
   -igor
  
  
   On Jan 31, 2008 3:49 PM, pnerkar [EMAIL PROTECTED] wrote:
  
   Hi All,
  
   I have rendered a list view on a Web Page.
  
   vehicle1X
   vehicle2X
   vehicle3X
  
   when a person click on 'X', that item should be deleted.
   But I'm facing an issue, when i click on 'X', last item get deleted.
   Actually when I delete vehicle2 from my list, it deletes vehicle2 but
   that
   component is still there.
   So while rendering it render vehicle1  vehicle2.
  
   public void onSubmit() {
   List vehicles = (List)
  getParent().getParent().getModelObject();
   vehicles.remove(index);
   }
  
   can please help out ??
  
  
  
   --
   View this message in context:
  
  http://www.nabble.com/How-to-delete-an-item-from-List-view.-tp15217608p15217608.html
   Sent from the Wicket - User mailing list archive at Nabble.com.
  
  
   -
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  
  
   -
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  
  
 
  --
  View this message in context:
  http://www.nabble.com/How-to-delete-an-item-from-List-view.-tp15217608p15218960.html
 
  Sent from the Wicket - User mailing list archive at Nabble.com.
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

 --
 View this message in context: 
 http://www.nabble.com/How-to-delete-an-item-from-List-view.-tp15217608p15219402.html

 Sent from the Wicket - User mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to delete an item from List view.

2008-01-31 Thread Timo Rantalaiho
On Thu, 31 Jan 2008, pnerkar wrote:
 public void onSubmit() {
   List vehicles = (List) getParent().getParent().getModelObject();
   vehicles.remove(index);
 }

As a cleaner way to do this you could try


  ListVehicle vehicles = findParent(VehiclesList.class).getModelObject();

  
Best wishes,
Timo

-- 
Timo Rantalaiho   +358-45-6709709
Reaktor Innovations OyURL: http://www.ri.fi/ 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to delete an item from List view.

2008-01-31 Thread Igor Vaynberg
if you want to talk about a cleaner way...

add(new removelink(remove, item.getmodel()) {
  onclick() {
   vehicles.remove(getmodelobject());
  }
}

assuming vehicles is a property on listview's parent...

-igor


On Jan 31, 2008 7:29 PM, Timo Rantalaiho [EMAIL PROTECTED] wrote:
 On Thu, 31 Jan 2008, pnerkar wrote:
  public void onSubmit() {
List vehicles = (List) getParent().getParent().getModelObject();
vehicles.remove(index);
  }

 As a cleaner way to do this you could try


   ListVehicle vehicles = findParent(VehiclesList.class).getModelObject();


 Best wishes,
 Timo

 --
 Timo Rantalaiho   +358-45-6709709
 Reaktor Innovations OyURL: http://www.ri.fi/ 


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to delete an item from List view.

2008-01-31 Thread Eelco Hillenius
On Jan 31, 2008 3:49 PM, pnerkar [EMAIL PROTECTED] wrote:

 Hi All,

 I have rendered a list view on a Web Page.

 vehicle1X
 vehicle2X
 vehicle3X

 when a person click on 'X', that item should be deleted.
 But I'm facing an issue, when i click on 'X', last item get deleted.
 Actually when I delete vehicle2 from my list, it deletes vehicle2 but that
 component is still there.
 So while rendering it render vehicle1  vehicle2.

 public void onSubmit() {
 List vehicles = (List) getParent().getParent().getModelObject();
 vehicles.remove(index);
 }

Instead of using ListView, you could consider RefreshingView with it's
itemReuseStrategy set to ReuseIfModelsEqualStrategy.

Eelco

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to delete an item from List view.

2008-01-31 Thread pnerkar

Hi igor,

I have tried this,

Now when I click on remove - it just clear all fields for vehicle2. But none
of them get deleted.
 
-pnerkar


igor.vaynberg wrote:
 
 try this:
 
 onpopulate (final listitem item) {
add(new link(remove) { onclick() { 
 item.getparent().remove(item); }}
 }
 
 -igor
 
 
 On Jan 31, 2008 6:19 PM, pnerkar [EMAIL PROTECTED] wrote:

 Hi igor,

 But If I remove setReuseItems(true), it'll remove all field values which
 user has entered will be removed.
 Bcz default processing  is false for Remove button (Sorry forget to tell
 you)
 I just want to remove vehicle2, but the values entered for vehicle1 
 vehicle3 should not be lost.


 - Pnerkar





 igor.vaynberg wrote:
 
  vehicles.setReuseItems(true); == that is what is causing your list to
  reuse old components
 
  -igor
 
 
  On Jan 31, 2008 5:36 PM, pnerkar [EMAIL PROTECTED] wrote:
 
  Hi,
 
  Following is my code for rendering vehicle list-
 
  final VehiclesList vehicles = new VehiclesList(vehicledetails,
  ((RatingRequestAuto)getModelObject()).getVehicles());
  vehicles.setOutputMarkupId(true);
  vehicles.setReuseItems(true);
  add(vehicles);
 
  private static class VehiclesList extends ListView {
 
 
  public VehiclesList (String id, List vehicles) {
  super (id, vehicles);
 
  }
 
  protected void populateItem(final ListItem item)
  {
 
  item.add(new TextField(vehicle.modelText, new
  PropertyModel(vehicle, model)).setRequired(true));
  TextField registrationnumber = new
  TextField(vehicle.registrationnumber, new PropertyModel(vehicle,
  registrationNumber));
  TextField engineNumber = new
  TextField(vehicle.enginenumber, new
  PropertyModel(vehicle, engineNumber));
 
  final int index = item.getIndex();
  Button remVehBtn = new Button(btn_removeVeh,
  new ResourceModel(
  removevehicle )) {
  public void onSubmit() {
  List vehicles = (List)
  getParent().getParent().getModelObject();
  vehicles.remove(index);
  }
  });
  }
  }
 
  Thanks a lot for ur reply :)
 
 
 
 
  igor.vaynberg wrote:
  
   show us how you populate your listview...
  
   -igor
  
  
   On Jan 31, 2008 3:49 PM, pnerkar [EMAIL PROTECTED] wrote:
  
   Hi All,
  
   I have rendered a list view on a Web Page.
  
   vehicle1X
   vehicle2X
   vehicle3X
  
   when a person click on 'X', that item should be deleted.
   But I'm facing an issue, when i click on 'X', last item get
 deleted.
   Actually when I delete vehicle2 from my list, it deletes vehicle2
 but
   that
   component is still there.
   So while rendering it render vehicle1  vehicle2.
  
   public void onSubmit() {
   List vehicles = (List)
  getParent().getParent().getModelObject();
   vehicles.remove(index);
   }
  
   can please help out ??
  
  
  
   --
   View this message in context:
  
 
 http://www.nabble.com/How-to-delete-an-item-from-List-view.-tp15217608p15217608.html
   Sent from the Wicket - User mailing list archive at Nabble.com.
  
  
  
 -
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  
  
  
 -
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  
  
 
  --
  View this message in context:
 
 http://www.nabble.com/How-to-delete-an-item-from-List-view.-tp15217608p15218960.html
 
  Sent from the Wicket - User mailing list archive at Nabble.com.
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

 --
 View this message in context:
 http://www.nabble.com/How-to-delete-an-item-from-List-view.-tp15217608p15219402.html

 Sent from the Wicket - User mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]


 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/How-to-delete-an-item-from-List-view.-tp15217608p15220830.html
Sent from the