I write the code like this

searchString.add(new AbstractBehavior(){
        private static final long serialVersionUID = 1L;
        
        @Override
        public void onComponentTag(Component component, ComponentTag tag) {
                tag.put("onkeydown", "if(event.keyCode==13)
{searchForm_search.click();return false;}");
        }
});

now, I can click the Enter when focus on TextField to submit form by ajax.
But I still can't understand why the second code I had write can work well.
I think there's some subtle difference between the two code render in IE6.

Thank you very much.

deafwolf



> this is a browser "feature"
>
> what you can do is add the behavior below to all textfields in the form
>
> /**
>  * Behavior that traps the enter key press
>  *
>  * @author ivaynberg
>  */
> public class EnterKeyTrap extends AbstractBehavior implements
> IHeaderContributor {
>    @Override
>    public void onComponentTag(Component component, ComponentTag tag) {
>        tag.put("onkeydown", "return ekt(event)!=13");
>    }
>
>    public void renderHead(Response response) {
>        response.write(JavascriptUtils.SCRIPT_OPEN_TAG);
>        response.write("function
> ekt(e){if(typeof(e.keyCode)==\"undefined\"){return
> e.which;}else{return e.keyCode;}}");
>        response.write(JavascriptUtils.SCRIPT_CLOSE_TAG);
>    }
> }
>
> -igor

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to