onLoad javascript event with Markup inheritance
Hi, I use Markup inheritance in my site in order to keep common logic in the base page. I would like my child pages to do certain javascript actions when they are loaded. I try to define the the javascript on the childs body (between the wicket:extend and /wicket:extend) but I don't see them in the generated page (the base + child page). Any Idea how to generate onLoad javascript action for child page? -- View this message in context: http://www.nabble.com/onLoad-javascript-event-with-Markup-inheritance-tp20681885p20681885.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: onLoad javascript event with Markup inheritance
Something like: HTML wicket:extend script wicket:id=script type=text/javascriptalert('Hi');/script . /wicket:extend Java code: Label script = new Label(script, new ModelString()) { private static final long serialVersionUID = 1L; @Override protected void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) { StringBuffer sb = new StringBuffer(); sb.append(var ); // some more Javascript code... replaceComponentTagBody(markupStream, openTag, sb.toString()); } }; addOrReplace(script); does not work? I use that kind of things for panel and works just fine... That should also work for extend... Best, Ernesto On Tue, Nov 25, 2008 at 3:08 PM, itayh [EMAIL PROTECTED] wrote: Hi, I use Markup inheritance in my site in order to keep common logic in the base page. I would like my child pages to do certain javascript actions when they are loaded. I try to define the the javascript on the childs body (between the wicket:extend and /wicket:extend) but I don't see them in the generated page (the base + child page). Any Idea how to generate onLoad javascript action for child page? -- View this message in context: http://www.nabble.com/onLoad-javascript-event-with-Markup-inheritance-tp20681885p20681885.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: onLoad javascript event with Markup inheritance
you should implement the IHeaderContributor interface in your page and use IHeaderResponse.renderOnLoadJavascript() method in the implementation of the renderHead method.. Ernesto Reinaldo Barreiro wrote: Something like: HTML wicket:extend script wicket:id=script type=text/javascriptalert('Hi');/script . /wicket:extend Java code: Label script = new Label(script, new ModelString()) { private static final long serialVersionUID = 1L; @Override protected void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) { StringBuffer sb = new StringBuffer(); sb.append(var ); // some more Javascript code... replaceComponentTagBody(markupStream, openTag, sb.toString()); } }; addOrReplace(script); does not work? I use that kind of things for panel and works just fine... That should also work for extend... Best, Ernesto On Tue, Nov 25, 2008 at 3:08 PM, itayh [EMAIL PROTECTED] wrote: Hi, I use Markup inheritance in my site in order to keep common logic in the base page. I would like my child pages to do certain javascript actions when they are loaded. I try to define the the javascript on the childs body (between the wicket:extend and /wicket:extend) but I don't see them in the generated page (the base + child page). Any Idea how to generate onLoad javascript action for child page? -- View this message in context: http://www.nabble.com/onLoad-javascript-event-with-Markup-inheritance-tp20681885p20681885.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: onLoad javascript event with Markup inheritance
You can use wicket:head or HeaderContributors. See http://cwiki.apache.org/WICKET/javascript-and-css-support.html this . Regards - Cemal http://www.jWeekend.co.uk http://jWeekend.co.uk itayh wrote: Hi, I use Markup inheritance in my site in order to keep common logic in the base page. I would like my child pages to do certain javascript actions when they are loaded. I try to define the the javascript on the childs body (between the wicket:extend and /wicket:extend) but I don't see them in the generated page (the base + child page). Any Idea how to generate onLoad javascript action for child page? http://cwiki.apache.org/WICKET/javascript-and-css-support.html http://cwiki.apache.org/WICKET/javascript-and-css-support.html -- View this message in context: http://www.nabble.com/onLoad-javascript-event-with-Markup-inheritance-tp20681885p20682066.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: onLoad javascript event with Markup inheritance
that would be a cleaner solution, indeed... but normally I use at most a couple of pages and lot of panel replacements so each component just contributes what it needs... On Tue, Nov 25, 2008 at 3:32 PM, Serkan Camurcuoglu [EMAIL PROTECTED] wrote: you should implement the IHeaderContributor interface in your page and use IHeaderResponse.renderOnLoadJavascript() method in the implementation of the renderHead method.. Ernesto Reinaldo Barreiro wrote: Something like: HTML wicket:extend script wicket:id=script type=text/javascriptalert('Hi');/script . /wicket:extend Java code: Label script = new Label(script, new ModelString()) { private static final long serialVersionUID = 1L; @Override protected void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) { StringBuffer sb = new StringBuffer(); sb.append(var ); // some more Javascript code... replaceComponentTagBody(markupStream, openTag, sb.toString()); } }; addOrReplace(script); does not work? I use that kind of things for panel and works just fine... That should also work for extend... Best, Ernesto On Tue, Nov 25, 2008 at 3:08 PM, itayh [EMAIL PROTECTED] wrote: Hi, I use Markup inheritance in my site in order to keep common logic in the base page. I would like my child pages to do certain javascript actions when they are loaded. I try to define the the javascript on the childs body (between the wicket:extend and /wicket:extend) but I don't see them in the generated page (the base + child page). Any Idea how to generate onLoad javascript action for child page? -- View this message in context: http://www.nabble.com/onLoad-javascript-event-with-Markup-inheritance-tp20681885p20681885.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: onLoad javascript event with Markup inheritance
Thank you, it works great. jWeekend wrote: You can use wicket:head or HeaderContributors. See http://cwiki.apache.org/WICKET/javascript-and-css-support.html this . Regards - Cemal http://www.jWeekend.co.uk http://jWeekend.co.uk itayh wrote: Hi, I use Markup inheritance in my site in order to keep common logic in the base page. I would like my child pages to do certain javascript actions when they are loaded. I try to define the the javascript on the childs body (between the wicket:extend and /wicket:extend) but I don't see them in the generated page (the base + child page). Any Idea how to generate onLoad javascript action for child page? http://cwiki.apache.org/WICKET/javascript-and-css-support.html http://cwiki.apache.org/WICKET/javascript-and-css-support.html -- View this message in context: http://www.nabble.com/onLoad-javascript-event-with-Markup-inheritance-tp20681885p20682858.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]