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() { >> >> >> 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. >> >> >> >> >> >> >> >> vehicle1 X >> >> >> >> vehicle2 X >> >> >> >> vehicle3 X >> >> >> >> >> >> >> >> 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.-tp15217608p15234458.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.-tp15217608p15236550.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]