Re: TextTemplateHeaderContributor from 1.4 to 6
Hi Martin, is it also eligible to put the body inside a behavior, i.e.: protected void addJavaScriptFile() { add( new Behavior() { @Override public void renderHead( final Component component, final IHeaderResponse response ) { super.renderHead( component, response ); PackageTextTemplate template = new PackageTextTemplate(ClassName.class,filename.js); MapString, Object variables = response.render(OnDomReadyHeaderItem. forScript(template.asString(variables))); The problem I'm facing is that the function addJavaScriptFile is accessable from subclasses which either call the function or not, i.e. only in a few cases the header should be actually added. Thanks, David 2015-03-16 15:16 GMT+01:00 Martin Grigorov mgrigo...@apache.org: Hi, #renderHead(IHeaderResponse response) { super.renderHead(response); PackageTextTemplate template = new PackageTextTemplate(ClassName.class, filename.js); MapString, Object variables = ... response.render(OnDomReadyHeaderItem.forScript(template.asString(variables))); } Martin Grigorov Freelancer, available for hire! Wicket Training and Consulting https://twitter.com/mtgrigorov On Mon, Mar 16, 2015 at 2:14 PM, David Kaufman david.kauf...@gmx.de wrote: Hello, I'm currently migrating a code snippet from version 1.4 to version 6: add( TextTemplateHeaderContributor.forJavaScript( ClassName.class, filename.js, new LoadableDetachableModelMapString, Object() { @Override protected MapString, Object load() { final MapString, Object result = new HashMapString, Object(); result.put( id, static string ); // more parameters here return result; } } ) ); The migration documentation ( https://cwiki.apache.org/confluence/display/WICKET/Migration+to+Wicket+1.5#MigrationtoWicket1.5-RemovedTextTemplateHeaderContributor/StringHeaderContributor ) suggests using a custom template, e.g. private TextTemplate template = CssTemplate(new MyTextTemplate()); Unfortunately, I can't find a TextTemplate which mimics the behavior in my 1.4 code snippet. I found a JavaScriptTemplate, but I was unable to find a way to use it, as it needs a TextTemplate instance in its constructor. Thanks, David
Re: TextTemplateHeaderContributor from 1.4 to 6
Yes, if you need to reuse it then put it in a Behavior! Martin Grigorov Freelancer, available for hire! Wicket Training and Consulting https://twitter.com/mtgrigorov On Tue, Mar 17, 2015 at 12:38 PM, David Kaufman david.kauf...@gmx.de wrote: Hi Martin, is it also eligible to put the body inside a behavior, i.e.: protected void addJavaScriptFile() { add( new Behavior() { @Override public void renderHead( final Component component, final IHeaderResponse response ) { super.renderHead( component, response ); PackageTextTemplate template = new PackageTextTemplate(ClassName.class,filename.js); MapString, Object variables = response.render(OnDomReadyHeaderItem. forScript(template.asString(variables))); The problem I'm facing is that the function addJavaScriptFile is accessable from subclasses which either call the function or not, i.e. only in a few cases the header should be actually added. Thanks, David 2015-03-16 15:16 GMT+01:00 Martin Grigorov mgrigo...@apache.org: Hi, #renderHead(IHeaderResponse response) { super.renderHead(response); PackageTextTemplate template = new PackageTextTemplate(ClassName.class, filename.js); MapString, Object variables = ... response.render(OnDomReadyHeaderItem.forScript(template.asString(variables))); } Martin Grigorov Freelancer, available for hire! Wicket Training and Consulting https://twitter.com/mtgrigorov On Mon, Mar 16, 2015 at 2:14 PM, David Kaufman david.kauf...@gmx.de wrote: Hello, I'm currently migrating a code snippet from version 1.4 to version 6: add( TextTemplateHeaderContributor.forJavaScript( ClassName.class, filename.js, new LoadableDetachableModelMapString, Object() { @Override protected MapString, Object load() { final MapString, Object result = new HashMapString, Object(); result.put( id, static string ); // more parameters here return result; } } ) ); The migration documentation ( https://cwiki.apache.org/confluence/display/WICKET/Migration+to+Wicket+1.5#MigrationtoWicket1.5-RemovedTextTemplateHeaderContributor/StringHeaderContributor ) suggests using a custom template, e.g. private TextTemplate template = CssTemplate(new MyTextTemplate()); Unfortunately, I can't find a TextTemplate which mimics the behavior in my 1.4 code snippet. I found a JavaScriptTemplate, but I was unable to find a way to use it, as it needs a TextTemplate instance in its constructor. Thanks, David
Re: TextTemplateHeaderContributor from 1.4 to 6
Hi, #renderHead(IHeaderResponse response) { super.renderHead(response); PackageTextTemplate template = new PackageTextTemplate(ClassName.class, filename.js); MapString, Object variables = ... response.render(OnDomReadyHeaderItem.forScript(template.asString(variables))); } Martin Grigorov Freelancer, available for hire! Wicket Training and Consulting https://twitter.com/mtgrigorov On Mon, Mar 16, 2015 at 2:14 PM, David Kaufman david.kauf...@gmx.de wrote: Hello, I'm currently migrating a code snippet from version 1.4 to version 6: add( TextTemplateHeaderContributor.forJavaScript( ClassName.class, filename.js, new LoadableDetachableModelMapString, Object() { @Override protected MapString, Object load() { final MapString, Object result = new HashMapString, Object(); result.put( id, static string ); // more parameters here return result; } } ) ); The migration documentation ( https://cwiki.apache.org/confluence/display/WICKET/Migration+to+Wicket+1.5#MigrationtoWicket1.5-RemovedTextTemplateHeaderContributor/StringHeaderContributor ) suggests using a custom template, e.g. private TextTemplate template = CssTemplate(new MyTextTemplate()); Unfortunately, I can't find a TextTemplate which mimics the behavior in my 1.4 code snippet. I found a JavaScriptTemplate, but I was unable to find a way to use it, as it needs a TextTemplate instance in its constructor. Thanks, David