Try this:
public class FocusBehavior extends AbstractBehavior { private static final long serialVersionUID = 1L; private Component component; @Override public void bind(final Component component) { this.component = component; component.setOutputMarkupId(true); } @Override public void renderHead(final IHeaderResponse response) { response.renderOnDomReadyJavascript("document.getElementById('" + component.getMarkupId() + "').focus();"); } } And do TextField bla = new Textfield(....); Bla.add(new FocusBeahvior()); Stefan -----Ursprüngliche Nachricht----- Von: Henry, Mike [GCG-PFS] [mailto:mike.he...@primerica.com] Gesendet: Freitag, 29. Oktober 2010 19:58 An: users@wicket.apache.org Betreff: set focus in Modal Window I have successfully set the focus on a text field in a Modal window but after it is closed and re-opened it no longer sets the focus to that field. If I reload the whole parent page it will work once but again If the modal window is closed and re-opened same problem. I have tried all of these with the same result: target.appendJavascript("document.findRepform.searchString.focus();"); target.focusComponent(((FindRepDetailsPanel)selectModalWindow.get("conte nt")).get("findRepform:searchString")); ((FindRepDetailsPanel)selectModalWindow.get("content")).get("findRepform :searchString").add(new DefaultFocusBehavior()) Any ideas? Thanks Mike --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org