well we have the new Wicket.Event thing you can use to install events. so
really what you do is create a javascript variable, then install a
'domready' event that traverses the dom tree looks for formcomponents  and
adds an onfocus event. then we just need to make the ajax stuff aware of
this.

see wicket-event.js and new method in iheaderresponse

i have also been bitten by this, and recently there was a thread on the list
about this as well.

-igor


On 2/19/07, Johan Compagner <[EMAIL PROTECTED]> wrote:

really?
matej, do tell!

i can work on it also because i really need it :)

johan


On 2/19/07, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
>
> yes, tracking is easy with our new event thing :)
>
> get on it matej!
>
> -igor
>
>
> On 2/19/07, Johan Compagner <[EMAIL PROTECTED]> wrote:
> >
> > attach an onfocus event on all focusable components
> > then have a javascript variable in the page that gets that assigned
> >
> > <input type="text" onfocus="lastfocuscomponent=this;MaybeAnAjaxCall">
> >
> > then i prepend a script that uses that lastfocuscomponent variable to
> get
> > the focus back in.
> > Ofcourse the onFocus event should be cleared or ignored for one time
if
> > there is an MaybeAnAjaxCall ...
> >
> > so the tracking is pretty easy, it is the handling after that.
> >
> > johan
> >
> >
> >
> > On 2/19/07, Matej Knopp <[EMAIL PROTECTED]> wrote:
> > >
> > > the question is, how exactly you want to track  the changing of
focus?
> > >
> > > -Matej
> > >
> > > Johan Compagner wrote:
> > > > if i have an ajax behavior on a text field event: onfocus
> > > >
> > > > and i set the background and then add that component to the ajax
> event
> > > for
> > > > redraw
> > > > then i loose focus. Ofcourse there are ways to go around that..
> > > > for example i could just write the style tag out instead of the
> > complete
> > > > component.
> > > > But what when it gets a bit harder? (like a parent is altered and
> > > > rerendered)
> > > >
> > > > i could attach a behavior (onfocus) to all components and let them
> set
> > > > the last know focus component. And then append to every ajax call
a
> > > script:
> > > > if (lastfocuscomponent) lastfocuscomponent.focus();
> > > > the problem with this is that this focus gained should be ignored
if
> > > there
> > > > was an ajax focus
> > > > gained event that the server wants to receive , else you could
have
> an
> > > > endless loop.
> > > >
> > > > Can't wicket do this for the developer?
> > > > so track the latest focus component when an ajax call is
dispatched.
> > And
> > > > when it returns
> > > > set the focus back (and then ignore that focus gained event...)
> > > >
> > > > johan
> > > >
> > >
> > >
> > >
> > >
> >
>

Reply via email to