You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by pnerkar <pn...@gmail.com> on 2008/02/01 00:49:10 UTC

How to delete an item from List view.

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


Re: How to delete an item from List view.

Posted by pnerkar <pn...@gmail.com>.
Hi Johan,

Actually that's not a main button of my page.
So default processing is set false, bcz of that the values will not be there
in model objects.

Regards,

Pankaj...


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 <pn...@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 <pn...@gmail.com> 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 <http://nabble.com/><http://nabble.com/>
>> >> .
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >> For additional commands, e-mail: users-help@wicket.apache.org
>> >>
>> >>
>> >
>> >
>>
>> --
>> 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<http://nabble.com/>
>> .
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> 

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


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


Re: How to delete an item from List view.

Posted by Major Péter <ma...@sch.bme.hu>.
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 Iterator<IModel> getItemModels()
>> 				{
>> 					List models = new ArrayList();
>>
>> 					for(int i=0;i<rows.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 <pn...@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 <pn...@gmail.com> 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 <http://nabble.com/><http://nabble.com/>
>>>>>> .
>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>> --
>>>> 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<http://nabble.com/>
>>>> .
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>
>>>
>>
>>
> 

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


Re: How to delete an item from List view.

Posted by prati <pr...@gmail.com>.
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 Iterator<IModel> getItemModels()
>>> 				{
>>> 					List models = new ArrayList();
>>> 
>>> 					for(int i=0;i<rows.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 <pn...@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 <pn...@gmail.com> 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 <http://nabble.com/><http://nabble.com/>
>>>>> >> .
>>>>> >>
>>>>> >>
>>>>> >>
>>>>> ---------------------------------------------------------------------
>>>>> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> >> For additional commands, e-mail: users-help@wicket.apache.org
>>>>> >>
>>>>> >>
>>>>> >
>>>>> >
>>>>>
>>>>> --
>>>>> 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<http://nabble.com/>
>>>>> .
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>> 
>>>> 
>>> 
>>> 
>> 
>> 
> 
> 

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


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


Re: How to delete an item from List view.

Posted by prati <pr...@gmail.com>.
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 Iterator<IModel> getItemModels()
>> 				{
>> 					List models = new ArrayList();
>> 
>> 					for(int i=0;i<rows.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 <pn...@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 <pn...@gmail.com> 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 <http://nabble.com/><http://nabble.com/>
>>>> >> .
>>>> >>
>>>> >>
>>>> >>
>>>> ---------------------------------------------------------------------
>>>> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> >> For additional commands, e-mail: users-help@wicket.apache.org
>>>> >>
>>>> >>
>>>> >
>>>> >
>>>>
>>>> --
>>>> 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<http://nabble.com/>
>>>> .
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>> 
>>> 
>> 
>> 
> 
> 

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


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


Re: How to delete an item from List view.

Posted by prati <pr...@gmail.com>.
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 Iterator<IModel> getItemModels()
> 				{
> 					List models = new ArrayList();
> 
> 					for(int i=0;i<rows.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 <pn...@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 <pn...@gmail.com> 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 <http://nabble.com/><http://nabble.com/>
>>> >> .
>>> >>
>>> >>
>>> >> ---------------------------------------------------------------------
>>> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> >> For additional commands, e-mail: users-help@wicket.apache.org
>>> >>
>>> >>
>>> >
>>> >
>>>
>>> --
>>> 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<http://nabble.com/>
>>> .
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>> 
>> 
> 
> 

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


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


Re: How to delete an item from List view.

Posted by prati <pr...@gmail.com>.
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 Iterator<IModel> getItemModels()
				{
					List models = new ArrayList();

					for(int i=0;i<rows.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 <pn...@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 <pn...@gmail.com> 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 <http://nabble.com/><http://nabble.com/>
>> >> .
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >> For additional commands, e-mail: users-help@wicket.apache.org
>> >>
>> >>
>> >
>> >
>>
>> --
>> 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<http://nabble.com/>
>> .
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> 

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


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


Re: How to delete an item from List view.

Posted by Igor Vaynberg <ig...@gmail.com>.
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 <jc...@gmail.com> 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 <pn...@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 <pn...@gmail.com> 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 <http://nabble.com/><http://nabble.com/>
> > >> .
> > >>
> > >>
> > >> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > >> For additional commands, e-mail: users-help@wicket.apache.org
> > >>
> > >>
> > >
> > >
> >
> > --
> > 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<http://nabble.com/>
>
> > .
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>

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


Re: How to delete an item from List view.

Posted by Johan Compagner <jc...@gmail.com>.
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 <pn...@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 <pn...@gmail.com> 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 <http://nabble.com/><http://nabble.com/>
> >> .
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
> >
> >
>
> --
> 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<http://nabble.com/>
> .
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: How to delete an item from List view.

Posted by pnerkar <pn...@gmail.com>.
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 <pn...@gmail.com> 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<http://nabble.com/>
>> .
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> 

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


Re: How to delete an item from List view.

Posted by Johan Compagner <jc...@gmail.com>.
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 <pn...@gmail.com> 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<http://nabble.com/>
> .
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: How to delete an item from List view.

Posted by Martijn Dashorst <ma...@gmail.com>.
see wicket-extensions
Martijn

On 2/1/08, pnerkar <pn...@gmail.com> 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 <pn...@gmail.com> 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);
> >> }
> >
> > Instead of using ListView, you could consider RefreshingView with it's
> > itemReuseStrategy set to ReuseIfModelsEqualStrategy.
> >
> > Eelco
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
> >
>
> --
> 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: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
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.

Posted by pnerkar <pn...@gmail.com>.
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 <pn...@gmail.com> 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);
>> }
> 
> Instead of using ListView, you could consider RefreshingView with it's
> itemReuseStrategy set to ReuseIfModelsEqualStrategy.
> 
> Eelco
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

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


Re: How to delete an item from List view.

Posted by Eelco Hillenius <ee...@gmail.com>.
On Jan 31, 2008 3:49 PM, pnerkar <pn...@gmail.com> 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);
> }

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

Eelco

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


Re: How to delete an item from List view.

Posted by Igor Vaynberg <ig...@gmail.com>.
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 <ee...@gmail.com> wrote:
> On Feb 2, 2008 2:19 PM, Igor Vaynberg <ig...@gmail.com> 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: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: How to delete an item from List view.

Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.
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 <ma...@gmail.com> wrote:
>   
>> On 2/3/08, Eelco Hillenius <ee...@gmail.com> 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: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>   

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


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


Re: How to delete an item from List view.

Posted by Eelco Hillenius <ee...@gmail.com>.
On Feb 4, 2008 3:45 AM, Martijn Dashorst <ma...@gmail.com> wrote:
> On 2/3/08, Eelco Hillenius <ee...@gmail.com> 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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How to delete an item from List view.

Posted by Martijn Dashorst <ma...@gmail.com>.
On 2/3/08, Eelco Hillenius <ee...@gmail.com> 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.

Posted by Eelco Hillenius <ee...@gmail.com>.
On Feb 2, 2008 2:19 PM, Igor Vaynberg <ig...@gmail.com> 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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How to delete an item from List view.

Posted by Igor Vaynberg <ig...@gmail.com>.
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 <a....@gmail.com> 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 <ig...@gmail.com> wrote:
> > read the notice part of the javadoc...
> >
> > -igor
> >
> >
> >
> > On Feb 1, 2008 5:49 PM, pnerkar <pn...@gmail.com> 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 <pn...@gmail.com> 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 <pn...@gmail.com> 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 <pn...@gmail.com> 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 <pn...@gmail.com> 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 <pn...@gmail.com> 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: users-unsubscribe@wicket.apache.org
> > > >> >> >> >> >> For additional commands, e-mail: users-help@wicket.apache.org
> > > >> >> >> >> >>
> > > >> >> >> >> >>
> > > >> >> >> >> >
> > > >> >> >> >> >
> > > >> >> >>
> > > >> ---------------------------------------------------------------------
> > > >> >> >> >> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > >> >> >> >> > For additional commands, e-mail: users-help@wicket.apache.org
> > > >> >> >> >> >
> > > >> >> >> >> >
> > > >> >> >> >> >
> > > >> >> >> >>
> > > >> >> >> >> --
> > > >> >> >> >> 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: users-unsubscribe@wicket.apache.org
> > > >> >> >> >> For additional commands, e-mail: users-help@wicket.apache.org
> > > >> >> >> >>
> > > >> >> >> >>
> > > >> >> >> >
> > > >> >> >> >
> > > >> >> ---------------------------------------------------------------------
> > > >> >> >> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > >> >> >> > For additional commands, e-mail: users-help@wicket.apache.org
> > > >> >> >> >
> > > >> >> >> >
> > > >> >> >> >
> > > >> >> >>
> > > >> >> >> --
> > > >> >> >> 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: users-unsubscribe@wicket.apache.org
> > > >> >> >> For additional commands, e-mail: users-help@wicket.apache.org
> > > >> >> >>
> > > >> >> >>
> > > >> >> >
> > > >> >> >
> > > >> ---------------------------------------------------------------------
> > > >> >> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > >> >> > For additional commands, e-mail: users-help@wicket.apache.org
> > > >> >> >
> > > >> >> >
> > > >> >> >
> > > >> >>
> > > >> >> --
> > > >> >> 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: users-unsubscribe@wicket.apache.org
> > > >> >> For additional commands, e-mail: users-help@wicket.apache.org
> > > >> >>
> > > >> >>
> > > >> >
> > > >> > ---------------------------------------------------------------------
> > > >> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > >> > For additional commands, e-mail: users-help@wicket.apache.org
> > > >> >
> > > >> >
> > > >> >
> > > >>
> > > >> --
> > > >> 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: users-unsubscribe@wicket.apache.org
> > > >> For additional commands, e-mail: users-help@wicket.apache.org
> > > >>
> > > >>
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > > For additional commands, e-mail: users-help@wicket.apache.org
> > > >
> > > >
> > > >
> > >
> > > --
> > > View this message in context: http://www.nabble.com/How-to-delete-an-item-from-List-view.-tp15217608p15238695.html
> > >
> > > Sent from the Wicket - User mailing list archive at Nabble.com.
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > For additional commands, e-mail: users-help@wicket.apache.org
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
>
>
> --
> Alan R.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: How to delete an item from List view.

Posted by Alan Romaniuc <a....@gmail.com>.
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 <ig...@gmail.com> wrote:
> read the notice part of the javadoc...
>
> -igor
>
>
>
> On Feb 1, 2008 5:49 PM, pnerkar <pn...@gmail.com> 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 <pn...@gmail.com> 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 <pn...@gmail.com> 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 <pn...@gmail.com> 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 <pn...@gmail.com> 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 <pn...@gmail.com> 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: users-unsubscribe@wicket.apache.org
> > >> >> >> >> >> For additional commands, e-mail: users-help@wicket.apache.org
> > >> >> >> >> >>
> > >> >> >> >> >>
> > >> >> >> >> >
> > >> >> >> >> >
> > >> >> >>
> > >> ---------------------------------------------------------------------
> > >> >> >> >> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > >> >> >> >> > For additional commands, e-mail: users-help@wicket.apache.org
> > >> >> >> >> >
> > >> >> >> >> >
> > >> >> >> >> >
> > >> >> >> >>
> > >> >> >> >> --
> > >> >> >> >> 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: users-unsubscribe@wicket.apache.org
> > >> >> >> >> For additional commands, e-mail: users-help@wicket.apache.org
> > >> >> >> >>
> > >> >> >> >>
> > >> >> >> >
> > >> >> >> >
> > >> >> ---------------------------------------------------------------------
> > >> >> >> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > >> >> >> > For additional commands, e-mail: users-help@wicket.apache.org
> > >> >> >> >
> > >> >> >> >
> > >> >> >> >
> > >> >> >>
> > >> >> >> --
> > >> >> >> 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: users-unsubscribe@wicket.apache.org
> > >> >> >> For additional commands, e-mail: users-help@wicket.apache.org
> > >> >> >>
> > >> >> >>
> > >> >> >
> > >> >> >
> > >> ---------------------------------------------------------------------
> > >> >> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > >> >> > For additional commands, e-mail: users-help@wicket.apache.org
> > >> >> >
> > >> >> >
> > >> >> >
> > >> >>
> > >> >> --
> > >> >> 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: users-unsubscribe@wicket.apache.org
> > >> >> For additional commands, e-mail: users-help@wicket.apache.org
> > >> >>
> > >> >>
> > >> >
> > >> > ---------------------------------------------------------------------
> > >> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > >> > For additional commands, e-mail: users-help@wicket.apache.org
> > >> >
> > >> >
> > >> >
> > >>
> > >> --
> > >> 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: users-unsubscribe@wicket.apache.org
> > >> For additional commands, e-mail: users-help@wicket.apache.org
> > >>
> > >>
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > For additional commands, e-mail: users-help@wicket.apache.org
> > >
> > >
> > >
> >
> > --
> > View this message in context: http://www.nabble.com/How-to-delete-an-item-from-List-view.-tp15217608p15238695.html
> >
> > Sent from the Wicket - User mailing list archive at Nabble.com.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>



-- 
Alan R.

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


Re: How to delete an item from List view.

Posted by Igor Vaynberg <ig...@gmail.com>.
read the notice part of the javadoc...

-igor


On Feb 1, 2008 5:49 PM, pnerkar <pn...@gmail.com> 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 <pn...@gmail.com> 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 <pn...@gmail.com> 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 <pn...@gmail.com> 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 <pn...@gmail.com> 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 <pn...@gmail.com> 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: users-unsubscribe@wicket.apache.org
> >> >> >> >> >> For additional commands, e-mail: users-help@wicket.apache.org
> >> >> >> >> >>
> >> >> >> >> >>
> >> >> >> >> >
> >> >> >> >> >
> >> >> >>
> >> ---------------------------------------------------------------------
> >> >> >> >> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> >> >> >> > For additional commands, e-mail: users-help@wicket.apache.org
> >> >> >> >> >
> >> >> >> >> >
> >> >> >> >> >
> >> >> >> >>
> >> >> >> >> --
> >> >> >> >> 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: users-unsubscribe@wicket.apache.org
> >> >> >> >> For additional commands, e-mail: users-help@wicket.apache.org
> >> >> >> >>
> >> >> >> >>
> >> >> >> >
> >> >> >> >
> >> >> ---------------------------------------------------------------------
> >> >> >> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> >> >> > For additional commands, e-mail: users-help@wicket.apache.org
> >> >> >> >
> >> >> >> >
> >> >> >> >
> >> >> >>
> >> >> >> --
> >> >> >> 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: users-unsubscribe@wicket.apache.org
> >> >> >> For additional commands, e-mail: users-help@wicket.apache.org
> >> >> >>
> >> >> >>
> >> >> >
> >> >> >
> >> ---------------------------------------------------------------------
> >> >> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> >> > For additional commands, e-mail: users-help@wicket.apache.org
> >> >> >
> >> >> >
> >> >> >
> >> >>
> >> >> --
> >> >> 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: users-unsubscribe@wicket.apache.org
> >> >> For additional commands, e-mail: users-help@wicket.apache.org
> >> >>
> >> >>
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> > For additional commands, e-mail: users-help@wicket.apache.org
> >> >
> >> >
> >> >
> >>
> >> --
> >> 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: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
> >
>
> --
> View this message in context: http://www.nabble.com/How-to-delete-an-item-from-List-view.-tp15217608p15238695.html
>
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: How to delete an item from List view.

Posted by pnerkar <pn...@gmail.com>.
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 <pn...@gmail.com> 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 <pn...@gmail.com> 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 <pn...@gmail.com> 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 <pn...@gmail.com> 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 <pn...@gmail.com> 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: users-unsubscribe@wicket.apache.org
>> >> >> >> >> For additional commands, e-mail: users-help@wicket.apache.org
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >> >
>> >> >> >> >
>> >> >>
>> ---------------------------------------------------------------------
>> >> >> >> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >> >> >> > For additional commands, e-mail: users-help@wicket.apache.org
>> >> >> >> >
>> >> >> >> >
>> >> >> >> >
>> >> >> >>
>> >> >> >> --
>> >> >> >> 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: users-unsubscribe@wicket.apache.org
>> >> >> >> For additional commands, e-mail: users-help@wicket.apache.org
>> >> >> >>
>> >> >> >>
>> >> >> >
>> >> >> >
>> >> ---------------------------------------------------------------------
>> >> >> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >> >> > For additional commands, e-mail: users-help@wicket.apache.org
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >>
>> >> >> --
>> >> >> 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: users-unsubscribe@wicket.apache.org
>> >> >> For additional commands, e-mail: users-help@wicket.apache.org
>> >> >>
>> >> >>
>> >> >
>> >> >
>> ---------------------------------------------------------------------
>> >> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >> > For additional commands, e-mail: users-help@wicket.apache.org
>> >> >
>> >> >
>> >> >
>> >>
>> >> --
>> >> 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: users-unsubscribe@wicket.apache.org
>> >> For additional commands, e-mail: users-help@wicket.apache.org
>> >>
>> >>
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> > For additional commands, e-mail: users-help@wicket.apache.org
>> >
>> >
>> >
>>
>> --
>> 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: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

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


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


Re: How to delete an item from List view.

Posted by Igor Vaynberg <ig...@gmail.com>.
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 <pn...@gmail.com> 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 <pn...@gmail.com> 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 <pn...@gmail.com> 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 <pn...@gmail.com> 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 <pn...@gmail.com> 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: users-unsubscribe@wicket.apache.org
> >> >> >> >> For additional commands, e-mail: users-help@wicket.apache.org
> >> >> >> >>
> >> >> >> >>
> >> >> >> >
> >> >> >> >
> >> >> ---------------------------------------------------------------------
> >> >> >> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> >> >> > For additional commands, e-mail: users-help@wicket.apache.org
> >> >> >> >
> >> >> >> >
> >> >> >> >
> >> >> >>
> >> >> >> --
> >> >> >> 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: users-unsubscribe@wicket.apache.org
> >> >> >> For additional commands, e-mail: users-help@wicket.apache.org
> >> >> >>
> >> >> >>
> >> >> >
> >> >> >
> >> ---------------------------------------------------------------------
> >> >> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> >> > For additional commands, e-mail: users-help@wicket.apache.org
> >> >> >
> >> >> >
> >> >> >
> >> >>
> >> >> --
> >> >> 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: users-unsubscribe@wicket.apache.org
> >> >> For additional commands, e-mail: users-help@wicket.apache.org
> >> >>
> >> >>
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> > For additional commands, e-mail: users-help@wicket.apache.org
> >> >
> >> >
> >> >
> >>
> >> --
> >> 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: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
> >
>
> --
> 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: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: How to delete an item from List view.

Posted by pnerkar <pn...@gmail.com>.
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 <pn...@gmail.com> 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 <pn...@gmail.com> 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 <pn...@gmail.com> 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 <pn...@gmail.com> 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: users-unsubscribe@wicket.apache.org
>> >> >> >> For additional commands, e-mail: users-help@wicket.apache.org
>> >> >> >>
>> >> >> >>
>> >> >> >
>> >> >> >
>> >> ---------------------------------------------------------------------
>> >> >> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >> >> > For additional commands, e-mail: users-help@wicket.apache.org
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >>
>> >> >> --
>> >> >> 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: users-unsubscribe@wicket.apache.org
>> >> >> For additional commands, e-mail: users-help@wicket.apache.org
>> >> >>
>> >> >>
>> >> >
>> >> >
>> ---------------------------------------------------------------------
>> >> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >> > For additional commands, e-mail: users-help@wicket.apache.org
>> >> >
>> >> >
>> >> >
>> >>
>> >> --
>> >> 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: users-unsubscribe@wicket.apache.org
>> >> For additional commands, e-mail: users-help@wicket.apache.org
>> >>
>> >>
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> > For additional commands, e-mail: users-help@wicket.apache.org
>> >
>> >
>> >
>>
>> --
>> 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: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

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


Re: How to delete an item from List view.

Posted by Igor Vaynberg <ig...@gmail.com>.
dont use a listview, use a refreshingview and provide an itemreuse strategy.

-igor


On Feb 1, 2008 1:51 PM, pnerkar <pn...@gmail.com> 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 <pn...@gmail.com> 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 <pn...@gmail.com> 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 <pn...@gmail.com> 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: users-unsubscribe@wicket.apache.org
> >> >> >> For additional commands, e-mail: users-help@wicket.apache.org
> >> >> >>
> >> >> >>
> >> >> >
> >> >> >
> >> ---------------------------------------------------------------------
> >> >> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> >> > For additional commands, e-mail: users-help@wicket.apache.org
> >> >> >
> >> >> >
> >> >> >
> >> >>
> >> >> --
> >> >> 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: users-unsubscribe@wicket.apache.org
> >> >> For additional commands, e-mail: users-help@wicket.apache.org
> >> >>
> >> >>
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> > For additional commands, e-mail: users-help@wicket.apache.org
> >> >
> >> >
> >> >
> >>
> >> --
> >> 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: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
> >
>
> --
> 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: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: How to delete an item from List view.

Posted by pnerkar <pn...@gmail.com>.
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 <pn...@gmail.com> 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 <pn...@gmail.com> 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 <pn...@gmail.com> 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: users-unsubscribe@wicket.apache.org
>> >> >> For additional commands, e-mail: users-help@wicket.apache.org
>> >> >>
>> >> >>
>> >> >
>> >> >
>> ---------------------------------------------------------------------
>> >> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >> > For additional commands, e-mail: users-help@wicket.apache.org
>> >> >
>> >> >
>> >> >
>> >>
>> >> --
>> >> 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: users-unsubscribe@wicket.apache.org
>> >> For additional commands, e-mail: users-help@wicket.apache.org
>> >>
>> >>
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> > For additional commands, e-mail: users-help@wicket.apache.org
>> >
>> >
>> >
>>
>> --
>> 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: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

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


Re: How to delete an item from List view.

Posted by pnerkar <pn...@gmail.com>.
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 <pn...@gmail.com> 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 <pn...@gmail.com> 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 <pn...@gmail.com> 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: users-unsubscribe@wicket.apache.org
>> >> >> For additional commands, e-mail: users-help@wicket.apache.org
>> >> >>
>> >> >>
>> >> >
>> >> >
>> ---------------------------------------------------------------------
>> >> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >> > For additional commands, e-mail: users-help@wicket.apache.org
>> >> >
>> >> >
>> >> >
>> >>
>> >> --
>> >> 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: users-unsubscribe@wicket.apache.org
>> >> For additional commands, e-mail: users-help@wicket.apache.org
>> >>
>> >>
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> > For additional commands, e-mail: users-help@wicket.apache.org
>> >
>> >
>> >
>>
>> --
>> 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: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

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


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


Re: How to delete an item from List view.

Posted by Igor Vaynberg <ig...@gmail.com>.
try this:

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

-igor


On Jan 31, 2008 6:19 PM, pnerkar <pn...@gmail.com> 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 <pn...@gmail.com> 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 <pn...@gmail.com> 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: users-unsubscribe@wicket.apache.org
> >> >> For additional commands, e-mail: users-help@wicket.apache.org
> >> >>
> >> >>
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> > For additional commands, e-mail: users-help@wicket.apache.org
> >> >
> >> >
> >> >
> >>
> >> --
> >> 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: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
> >
>
> --
> 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: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: How to delete an item from List view.

Posted by pnerkar <pn...@gmail.com>.
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 <pn...@gmail.com> 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 <pn...@gmail.com> 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: users-unsubscribe@wicket.apache.org
>> >> For additional commands, e-mail: users-help@wicket.apache.org
>> >>
>> >>
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> > For additional commands, e-mail: users-help@wicket.apache.org
>> >
>> >
>> >
>>
>> --
>> 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: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

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


Re: How to delete an item from List view.

Posted by Igor Vaynberg <ig...@gmail.com>.
vehicles.setReuseItems(true); <== that is what is causing your list to
reuse old components

-igor


On Jan 31, 2008 5:36 PM, pnerkar <pn...@gmail.com> 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 <pn...@gmail.com> 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: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
> >
>
> --
> 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: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: How to delete an item from List view.

Posted by pnerkar <pn...@gmail.com>.
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 <pn...@gmail.com> 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: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

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


Re: How to delete an item from List view.

Posted by Igor Vaynberg <ig...@gmail.com>.
show us how you populate your listview...

-igor


On Jan 31, 2008 3:49 PM, pnerkar <pn...@gmail.com> 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: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: How to delete an item from List view.

Posted by Igor Vaynberg <ig...@gmail.com>.
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 <Ti...@ri.fi> 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
>
>
>   List<Vehicle> vehicles = findParent(VehiclesList.class).getModelObject();
>
>
> Best wishes,
> Timo
>
> --
> Timo Rantalaiho           +358-45-6709709
> Reaktor Innovations Oy    <URL: http://www.ri.fi/ >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: How to delete an item from List view.

Posted by Timo Rantalaiho <Ti...@ri.fi>.
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


  List<Vehicle> vehicles = findParent(VehiclesList.class).getModelObject();

  
Best wishes,
Timo

-- 
Timo Rantalaiho           +358-45-6709709
Reaktor Innovations Oy    <URL: http://www.ri.fi/ >

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