Re: [Wicket-user] How to auto-eliminate component from RepeatingView
Felipe Piccolini bluesoft.cl> writes: > How can I do to make the "delete this person" works in order to > get it removed from the RepeatingView? Several issues: 1) The repeating view should be associated with each item in the list, not the list itself. 2) If you delete an item from the list, you have to refresh the whole list. 3) To delete an item, you need to delete your "person" component (the parent of the ajax link), not the ajax link itself. Here is some sample code that works: -. delete 01 public class Group extends WebPage { public Group() { final WebMarkupContainer pl = new WebMarkupContainer("personalList"); pl.setOutputMarkupId(true); final RepeatingView v = new RepeatingView("person"); for (int i = 0; i < 3; i++) { WebMarkupContainer p = new WebMarkupContainer(Integer.toString(i)); p.add(new AjaxLink("delPerson") { public void onClick( AjaxRequestTarget target) { v.remove(getParent()); target.addComponent(pl); } }); p.add(new Label("idPerson", Integer.toString(i))); v.add(p); } pl.add(v); add(pl); } } - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] How to auto-eliminate component from RepeatingView
Well, if I understood it right, then its quite easy: you have a "personalList" where you add(Component c) to - you can replace that by addOrReplace(Component c) and if there is a Component with Tag "foo" there then it will be replaced, else it will be put to it. You can also use .remove(Component C) or .remove(String id) to remove a component whose given IDs match - so, the .remove would be the answer to your question. Be sure to checkout the examples at: http://wicketstuff.org/wicket13/ and especially: http://wicketstuff.org/wicket13/repeater/ and how AJAX should work, as your AJAX code looks quite odd to me http://wicketstuff.org/wicket13/ajax/ (to use AJAX you need to manipulate the markupcontaier wich doesnt work with a repeater like ListView or RepeatingView unless you span a WebMarkupContainer around it - explained in wiki: http://cwiki.apache.org/WICKET/how-to-repaint-a-listview-via-ajax.html ) However, i suggest you to get it working with a usual Link first, and then try to AJAXify it, Regards _ Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von Felipe Piccolini Gesendet: Mittwoch, 23. Mai 2007 22:13 An: wicket-user@lists.sourceforge.net Betreff: [Wicket-user] How to auto-eliminate component from RepeatingView Hi, I'm new to wicket and I'm trying to do a sort of nested list of components, but each list's item (component) has not just info about the model, but also has links to delete/modify itself from the list... so I have this html code... Group.html: and Person.html: -. 01 So the Group.java gets the PersonModel and adds a new Person component to the RepeatingView... RepeatingView personalList = new RepeatingView("personalList"); for (Iterator iter = personalModelList.iterator(); iter.hasNext();) { PersonModel personModel = (PersonModel) iter.next(); final Person oPerson = new Person("person", personModel); personalList.add(oPerson); } add(personalList); My question is this: How can I do to make the "delete this person" works in order to get it removed from the RepeatingView? I was trying this code inside the Person.java so the component (item from the list) can activate the auto-remove from the list, but doesn't work: final AjaxLink delPersonaRel = new AjaxLink("delPersonLink"){ public void onClick(final AjaxRequestTarget target) { getParent().remove(this); System.out.println("person deleted"); target.addComponent(getParent()); } }; Any suggestion appreciated. Felipe Piccolini M. <mailto:[EMAIL PROTECTED]> [EMAIL PROTECTED] - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
[Wicket-user] How to auto-eliminate component from RepeatingView
Hi, I'm new to wicket and I'm trying to do a sort of nested list of components, but each list's item (component) has not just info about the model, but also has links to delete/modify itself from the list... so I have this html code... Group.html: and Person.html: -. src="res/btn_del.jpg"/> src="res/btn_mod.jpg"/> 01 So the Group.java gets the PersonModel and adds a new Person component to the RepeatingView... RepeatingView personalList = new RepeatingView("personalList"); for (Iterator iter = personalModelList.iterator(); iter.hasNext();) { PersonModel personModel = (PersonModel) iter.next(); final Person oPerson = new Person("person", personModel); personalList.add(oPerson); } add(personalList); My question is this: How can I do to make the "delete this person" works in order to get it removed from the RepeatingView? I was trying this code inside the Person.java so the component (item from the list) can activate the auto-remove from the list, but doesn't work: final AjaxLink delPersonaRel = new AjaxLink("delPersonLink"){ public void onClick(final AjaxRequestTarget target) { getParent().remove(this); System.out.println("person deleted"); target.addComponent(getParent()); } }; Any suggestion appreciated. Felipe Piccolini M. [EMAIL PROTECTED] - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user