OK, I figured it out..

I can add javascript like this using add(new StringHeaderContributor("insert my javascript here"));:


public class MyPage extends WebPage  {
        public MyPage(long sessionKey, String uniqueUsername) {
                String js  = "<script type='text/javascript'>" +
                                "ScriptSessionListener.notifyNewSessionClient(" 
+
                                sessionKey  +
                                ", '" +
                                uniqueUsername +
                                "');</script>";
                add(new StringHeaderContributor(js));
        }
}

(of course the tidier version would be just to write out the variables, and have the js fn static on the page, but same deal)

Thx
Joel



--------------------------------------------------
From: "Joel Halbert" <[EMAIL PROTECTED]>
Sent: Friday, March 28, 2008 9:22 AM
To: <[email protected]>
Subject: creating dynamic text in web page

Hi All,

I would like to be able to insert text dynamically in a wicket web page.
An example would be where the arguments for a JavaScript function need to by dynamic:


For example if I have something like this in my web page:
<script type='text/javascript'>

MyJavascriptObject.callMethod( ${sessionKey}, '${uniqueUsername}');

</script>



I would like the values of ${sessionKey} and ${uniqueUsername} to be populated dynamically.



Many Thanks,



Joel Halbert



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to