You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Patrick Fong <pf...@unimelb.edu.au> on 2009/05/20 03:57:55 UTC

Adding Javascript using Wicket onto a page that is not the header

Hi

I want to add Javascript which loads Javascript client side variables when a
page loads. It would call a Javascript function and pass in server-side
values. 

Typically to add HTML text I would do a add(new Label(id, "Blah"));

However, I want to add a Javascript function that would be enclosed in
<script> tags and after the form. This Javascript is not part of the header.

I've tried to add variables using the new Label(id, new
Model("alert('hello');")), but the single quotes are escaped.

I've looked into the following for some hints
*  
http://www.nabble.com/legacy-javascript-integration-td8454107.html#a8460179
* http://cwiki.apache.org/WICKET/adding-javascript-from-wicket.html

I know it is something to do with JavascriptTemplate. But I was hoping that
someone would shed some light into how to use. The Javascript goes something
like this ­ setVariables(Œ3¹, Œ1¹);

Cheers
Patrick

Re: Adding Javascript using Wicket onto a page that is not the header

Posted by Jeremy Thomerson <je...@wickettraining.com>.
setEscapeModelStrings(false) on your label

--
Jeremy Thomerson
http://www.wickettraining.com




On Tue, May 19, 2009 at 8:57 PM, Patrick Fong <pf...@unimelb.edu.au> wrote:
> Hi
>
> I want to add Javascript which loads Javascript client side variables when a
> page loads. It would call a Javascript function and pass in server-side
> values.
>
> Typically to add HTML text I would do a add(new Label(id, "Blah"));
>
> However, I want to add a Javascript function that would be enclosed in
> <script> tags and after the form. This Javascript is not part of the header.
>
> I've tried to add variables using the new Label(id, new
> Model("alert('hello');")), but the single quotes are escaped.
>
> I've looked into the following for some hints
> *
> http://www.nabble.com/legacy-javascript-integration-td8454107.html#a8460179
> * http://cwiki.apache.org/WICKET/adding-javascript-from-wicket.html
>
> I know it is something to do with JavascriptTemplate. But I was hoping that
> someone would shed some light into how to use. The Javascript goes something
> like this ­ setVariables(Œ3¹, Œ1¹);
>
> Cheers
> Patrick
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org