> 
> 2) Question: The component does some javascript handling like this:
> 
>     @Override
>     public void printHead(HtmlHeaderContainer container) {
>         super.printHead(container);
>         container.getResponse().write("<script type=\"text/javascript
> \">"+
>                 "function testFunction(select) {"+
>                 "    alert(select);"+
>                 "}"+
>                 "</script>");
>     }
> 
> 
>     protected void onComponentTag(final ComponentTag tag)
>     {
>         checkComponentTag(tag, "select");
>         tag.put("onChange", "testFunction(this);");
>         super.onComponentTag(tag);
>     }
> 
> Is this the "right" way to use JavaScript with Wicket 1.1b2? Is there
> an easy way to prevent the javascript function occuring multiple
> times if the component is used multiple times?
> 

<wicket:head>
   <script type=\"text/javascript\">
       function testFunction(select) { alert(select); }
   </script>
</wicket:head>
<wicket:panel>
...
</wicket:panel>

Add it to your panels markup. Wicket makes sure that it is added only
once.. Please see the test cases in /test/src/.... and the wiki as
well

Juergen


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to