Thanks guys. The setVisible(false) has solved the problem :).I want now to let the user add a number of this panel dynamically. Any help is welcome.
My code till now: private void addIngredientsPart(Recipe recipe) { if (recipe.getRecipeIngredients().size() == 0 ) { for (int i = 0; i < 3; i++) { recipe.addRecipeIngredient(new RecipeIngredient(recipe, new Ingredient(""), "")); } } final WebMarkupContainer container = new WebMarkupContainer("container"); container.setOutputMarkupId(true); container.add(new ListView<RecipeIngredient>("ingredients", recipe.getRecipeIngredients()) { @Override protected void populateItem(final ListItem<RecipeIngredient> item) { RecipeIngredient recipeIngredient = item.getModelObject(); item.add(new IngredientPanel("ingredientPanel", new Model<RecipeIngredient>(recipeIngredient))); } }); add(new AjaxLink<Void>("addLink") { @Override public void onClick(AjaxRequestTarget target) { // How can I now add a new IngredientPanel to the ListView? target.addComponent(container); } }); add(container); } Gr. Hbiloo On Tue, Feb 3, 2009 at 10:36 AM, Thomas Mäder <thomas.mae...@devotek-it.ch>wrote: > And don't forget that you have to add any components you want updated to > the > AjaxRequestTarget you get passed into the onClick() method. > > Thomas > > On Tue, Feb 3, 2009 at 7:43 AM, Jeremy Thomerson > <jer...@wickettraining.com>wrote: > > > A couple of problems: > > > > 1 - don't remove it. You should make it invisible (setVisible(false)) > > > > 2 - you're trying to remove the container from the link, but it was added > > to the panel. You would have to call IngredientPanel.this.remove (but > > don't) > > > > > > Jeremy Thomerson > > http://www.wickettraining.com > > -- sent from a wireless device > > > > > > -----Original Message----- > > From: Martin Makundi <martin.maku...@koodaripalvelut.com> > > Sent: Tuesday, February 03, 2009 12:16 AM > > To: users@wicket.apache.org > > Subject: Re: Component doesn't disappear when removing it via an ajax > link > > > > Run Wicket in development mode and investigate what happens in the > > "Wicket Ajax Debug" dialog (right bottom corner of your browser). > > > > ** > > Martin > > > > 2009/2/3 Azzeddine Daddah <waarhei...@gmail.com>: > > > Hi, > > > I've two text fields wrapped in a container. What I want to do is to > let > > the > > > user remove these fields via a link. This is my code which does not > work. > > > The wrapper container stills appear even the link is submitted: > > > > > > <html xmlns:wicket> > > > <wicket:panel> > > > <div wicket:id="container"> > > > <input type="text" wicket:id="recipeIngredientQty" style="width: > 15%; > > > float: left; margin-right: 10px;"/> > > > <input type="text" wicket:id="recipeIngredient" style="width: 80%; > > > margin-bottom: 7px;"/> > > > <a wicket:id="removeLink">[x]</a> > > > </div> > > > </wicket:panel> > > > </html> > > > > > > public class IngredientPanel extends Panel { > > > > > > /** > > > * Creates a new {...@link IngredientPanel}. > > > * > > > * @param id the panel id; may not be <code>null</code> > > > * @param model the panel model; may not be <code>null</code> > > > */ > > > public IngredientPanel(String id, IModel<RecipeIngredient> model) { > > > super(id, model); > > > RecipeIngredient recipeIngredient = model.getObject(); > > > > > > final WebMarkupContainer container = new > > > WebMarkupContainer("container", model); > > > container.setOutputMarkupId(true); > > > container.add(new > RequiredTextField<String>("recipeIngredientQty", > > > new Model<String>(recipeIngredient.getQuantity()))); > > > container.add(new RequiredTextField<String>("recipeIngredient", > > new > > > Model<String>(recipeIngredient.getIngredient().getName()))); > > > container.add(new AjaxLink<Void>("removeLink") { > > > @Override > > > public void onClick(AjaxRequestTarget target) { > > > remove(container); > > > } > > > }); > > > add(container); > > > } > > > } > > > > > > Kind regards, > > > > > > Hbiloo > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > > For additional commands, e-mail: users-h...@wicket.apache.org > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > > For additional commands, e-mail: users-h...@wicket.apache.org > > > > > > > -- > Thomas Mäder > www.devotek-it.ch >