Or, if you need to parameterize a larger portion of javascript,
you can use TextTemplates. (see DatePicker in wicket-datetime
as an example)

  Gerolf

On Fri, Mar 28, 2008 at 11:46 AM, Martijn Dashorst <
[EMAIL PROTECTED]> wrote:

> Another option:
>
> add(new Label("js", "<script
>
> type=\"text/javascript\">alert('foo');</script>").setEscapeModelStrings(false));
>
> On 3/28/08, Joel Halbert <[EMAIL PROTECTED]> wrote:
> > 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]
> >
> >
>
>
> --
> Buy Wicket in Action: http://manning.com/dashorst
> Apache Wicket 1.3.2 is released
> Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.2
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to