Thanks for the suggestions but I don't like either of these solutions.

First one involving the use of the label is the hack to which I have already
referred. In my case I am extending DropDownChoice and it would be messy to
require a special label component to go with it. I want to use just the one
component. If I make it a panel, then I lose the advantage of allowing the
<select> and <option> tags to be used directly.

The 2nd option is also a pain. The script needs to be invoked when the page
is being loaded. To invoke script in the header means calling it from body
onload etc. Much simpler to just have the script inline after the component
html.

I am investigating now whether I might be able to by overriding
DropDownChoice.onRender().

Maybe a new behavior would be a more generic solution.

Any other ideas would be welcome...
    

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:wicket-user-
> [EMAIL PROTECTED] On Behalf Of Alex Objelean
> Sent: Wednesday, 23 May 2007 5:02 PM
> To: wicket-user@lists.sourceforge.net
> Subject: Re: [Wicket-user] Best way to insert inline Javascript
> 
> 
> 
> There is at least two solutions.
> 1. The ideea is to use <script> tag as a Label component and its
> modelObject
> contains a generated script....
> http://www.nabble.com/Feedbackmessages%3A-extend-by-new-type-ALERT---
> tf3795933.html
> see this post .
> 
> 2. Use TextTemplateHeaderContributor for adding javascript - you can also
> interpolate variables inside it.
> 
> component.add(TextTemplateHeaderContributor.forJavaScript(getClass(),"mysc
> ript.js",
> variables));
> 
> 
> 
> 
> Mark van Leeuwen wrote:
> >
> > Writing my first custom component...
> >
> > I want to initialise the component using inline Javascript placed
> > immediately after the component markup.
> >
> > Searching the message archive I found one solution which is to use a
> label
> > to output the script. Seems a bit of a hack.
> >
> > Is there a better way?
> >
> >
> 
> --
> View this message in context: http://www.nabble.com/Best-way-to-insert-
> inline-Javascript-tf3802007.html#a10758551
> Sent from the Wicket - User mailing list archive at Nabble.com.
> 
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to