use target.(pre|append)Javascript if you want additional JS executed before/after doing the wicket-ajax stuff
if you only want to set the focus (without any ajax involved), don't use ajaxlink, use e.g. a simple WebmarkupContainer hth, michael Philipp Daumke-2 wrote: > > Dear all, > > I try to show and focus on a text field when clicking on a link. The > focus however doesn't work. I tried to follow an example in cwiki > (http://cwiki.apache.org/WICKET/calling-javascript-function-on-wicket-components-onclick.html) > > but I somehow do something wrong. I tried to add some javascript > attribute via AttributeAppender, but then I get a null pointer exception > in onClick ("target is null"). When I comment that line out (so don't > add the Attribute), everything works fine except that focus doesn't work. > > Any help appreciated. > Thanks a lot > Philipp > > Here's my code: > > in a WebMarkupContainer: > link.add(new AttributeAppender("onClick", new > Model("getElementById('"+textfield.getMarkupId()+ "').onFocus();"), ";")); > > in my custom Link Class: > public void onClick(AjaxRequestTarget target) > { > showFormThatContainsTextField(target); > } > > void showFormThatContainsTextField(AjaxRequestTarget target) > { > // toggle the visibility > ... > // redraw the add container. > target.addComponent(this); > } > > -- > > Averbis GmbH > c/o Klinikum der Albert-Ludwigs-Universität > Stefan-Meier-Strasse 26 > D-79104 Freiburg > > Fon: +49 (0) 761 - 203 6707 > Fax: +49 (0) 761 - 203 6800 > E-Mail: [email protected] > > Geschäftsführer: Dr. med. Philipp Daumke, Kornél Markó > Sitz der Gesellschaft: Freiburg i. Br. > AG Freiburg i. Br., HRB 701080 > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > > ----- Michael Sparer http://techblog.molindo.at -- View this message in context: http://www.nabble.com/Focus-on-component-tp21727553p21730148.html Sent from the Wicket - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
