Hello,

I used Igor's template below for something else. Just like in the 
example I add a generic javascript function to the header.
However, the function is added once for every time I add the behavior to 
an component in the page.
Who knows a clean way to prevent this?

Regards,
    Erik.


Igor Vaynberg schreef:
> 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

-- 
Erik van Oosten
http://www.day-to-day-stuff.blogspot.com/


-------------------------------------------------------------------------
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