set foucs on a feedback component with Apache Wicket

81 Views Asked by At

How can I add a focus behavior to a feedback component in a panel?

Searching leads to very little information, mostly on setting the default field. I do not want to set a default field, rather I am looking to set focus

1

There are 1 best solutions below

0
martin-g On

You could focus a Component by using AjaxRequestTarget.focusComponent(feedbackPanel).

There are two preconditions for this to work:

  • the HTML element used for the FeedbackPanel has to be focusable, i.e. to have a tabindex attribute
  • the HTML element used for the FeedbackPanel has to have an id attribute (feedbackPanel.setOutputMarkupId(true)), so that Wicket Ajax can look it up and set the focus on it