Re: this has to be easier.....

2007-02-19 Thread Matej Knopp

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







Re: this has to be easier.....

2007-02-19 Thread Igor Vaynberg

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
 







Re: this has to be easier.....

2007-02-19 Thread Igor Vaynberg

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
   
  
  
  
  
 




Re: this has to be easier.....

2007-02-19 Thread Johan Compagner

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
   
  
  
  
  
 





Re: this has to be easier.....

2007-02-19 Thread Igor Vaynberg

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

   
   
   
   
  
 





Re: this has to be easier.....

2007-02-19 Thread Johan Compagner

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