If you only need one TextField that should be displayed upon click on a button:
final TextField textField = new TextField("textField", new Model()); textField.setVisible(false); add(textField); AjaxButton button = new AjaxButton("button") { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { textField.setVisible(true); target.add(textField); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { } }; add(button); If you need to display a new TextField upon *each* click on the button: use a repeater (e.g. RepeatingView and friends). Cheers, -Tom On 29.11.2011, 09:04h tech7 wrote: > Many thanks. > > I am also trying to add new textfield to the page when user clicks on a > button. > How can I do that? Is there any proper way? > > > ----- > Wicket-Java > -- > View this message in context: > http://apache-wicket.1842946.n4.nabble.com/Dynamically-choosing-component-to-add-tp3955869p4118343.html > Sent from the Users forum mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > 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