If you need to change focus from the server side:
textField.add(new AjaxFormComponentUpdatingBehavior("onblur") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
target.addComponent(MyPanel.this);
String scriptStart =
"document.getElementById('";
String scriptEnd = "').focus()";
if (textField.hasErrorMessage()) {
target.appendJavascript(scriptStart +
textField.getMarkupId() + scriptEnd);
} else if (aCondition) {
target.appendJavascript(scriptStart
+
firstPanel.getFirstFocusableComponent().getMarkupId() + scriptEnd);
} else {
target.appendJavascript(scriptStart
+
secondPanel.getFirstFocusableComponent().getMarkupId() + scriptEnd);
}
}
});
/Raluca
On 9/21/07, Gwyn Evans <[EMAIL PROTECTED]> wrote:
> On Thursday, September 20, 2007, 11:43:45 PM, Doug <[EMAIL PROTECTED]> wrote:
>
> > I know this is probably one of the most trivial things to do...but I am
> > stumped. No example that I found on the Wicket example site has shown this.
> > I know that AjaxRequestTarget#focusComponent plays a part in this but not
> > sure how. Could someone post a quick code snippet or place on the Wiki on
> > how do to this in 1.3?
>
> Well, the basic code you need is just a
> <script language="JavaScript">
> document.myform.myinput.focus();
> </script>
> in the markup (if you use <body onLoad...> you may find it being
> executed before that page if fully loaded) but I've not tried using
> Wicket to tweak it.
>
> /Gwyn
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]