Hi,

i'm trying to implement a kind of "onfocus" event for a TextField but I 
don't know how to do this exactly.

I found the AjaxEventBehavior in the mailinglist but don't know how to use 
it right.

Here is my sample:

public class MyAjaxTextField extends TextField{

        public MyAjaxTextField(String arg0) {
                super(arg0);
 
        }
 
        public MyAjaxTextField(String arg0, IModel model) {
                super(arg0,model);
                PropertyModel pm = (PropertyModel)model;
                Person person = (Person)pm.getTarget();
 
                this.add(new MyAjaxEventBehavior("onfocus"));
        }
}

#########################################################

public class MyAjaxEventBehavior extends AjaxEventBehavior{

        public MyAjaxEventBehavior(String event) {
                super(event);
        }

        @Override
        protected void onEvent(AjaxRequestTarget target) {
                System.out.println("MyAjaxEventBehavior called.");
 
        }
}


So this works fine an the "MyAjaxEventBehavior called" is written to the 
console but it is written every time. It doesn't matter if it is "onfocus" 
or "onblur" or whatever.

How do I have to change things that only by "onfocus" the System.out part 
is being displayed?

Fabian

Reply via email to