that would be the best thing
because doing it serverside is a bad thing
because the user could already be jumping to another field and then
it always is restored to the one you think it is on the serverside

The best thing is attaching it on the onfocus event on the client side
and record it.
and after a ajax request always do onfocus on this except when we
do call it on the server side explicitly !

johan


On 2/19/07, Igor Vaynberg <[EMAIL PROTECTED]> wrote:

if you want something specific then you can already do ajaxtarget.focus()

ajaxtarget.appendjavascript("document.getelementbyid
('"+c.getmarkupid()+"').focus();")

if you want this more general so it works transparently its trickier. then
like you said you need to keep track of focus in a var and append it to
ajax
urls. which we can do. this new event stuff allows us to attach onfocus
event to everything so we can track it easily.

-igor


On 2/19/07, Johan Compagner <[EMAIL PROTECTED]> wrote:
>
> What i want is this:
>
> component.add(new ajaxbehaviour("onfocus"))
>
> then in the onEvent i do
>
> ajaxtarget.add(component)
>
> but then the focus is gone.
>
> So what should happen is that the focus is tracked on the page
> and when a ajax request comes back then it does focus() again.
>
> What we also can do is that i do it on the server side:
>
> onEvent(AjaxTarget)
> {
>   ajaxtarget.add(component);
>   ajaxtarget.setFocus(component,ignoreEvents)
> }
>
> then i can controll it on the serverside completely
>
> johan
>
> 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