Re: [MIGRATE 1.5] NPE trying to use JavaScriptTemplate

2011-04-22 Thread Pedro Santos
Move to 1.5-RC3, if this problem remains report in
https://issues.apache.org/jira/browse/WICKET-3187

On Fri, Apr 22, 2011 at 7:26 PM, Alexandros Karypidis wrote:

> Hi,
>
> I've just started preparing for 1.5 and have been modifying my code in
> order to conform with the new API. I've managed to get my application to
> compile and launch, but in my first attempt to render a page I get an NPE as
> follows:
>
> java.lang.NullPointerException
> at
> org.apache.wicket.util.template.TextTemplateDecorator.setLastModified(TextTemplateDecorator.java:195)
> at
> org.apache.wicket.util.resource.AbstractStringResourceStream.(AbstractStringResourceStream.java:76)
> at
> org.apache.wicket.util.resource.AbstractStringResourceStream.(AbstractStringResourceStream.java:62)
> at
> org.apache.wicket.util.template.TextTemplate.(TextTemplate.java:42)
> at
> org.apache.wicket.util.template.TextTemplateDecorator.(TextTemplateDecorator.java:52)
> at
> org.apache.wicket.util.template.JavaScriptTemplate.(JavaScriptTemplate.java:42)
> at assets.wicket.ovimaps.OviMap.renderHead(OviMap.java:46)
> at org.apache.wicket.Component.renderHead(Component.java:2644)
>
> Now this part of the code is an adaptation of what used to be a
> template-based javascript header contribution as follows:
>
> add(TextTemplateHeaderContributor.forJavaScript(OviMap.class,
> "OviMap.js", model));
>
> The above has been removed from the component constructor (where it used to
> be) and replaced with the following in code inside my component:
>
> @Override
> public void renderHead(IHeaderResponse response) {
>  super.renderHead(response);
>  JavaScriptTemplate template = new JavaScriptTemplate(
>   new PackagedTextTemplate(OviMap.class, "OviMap.js"));
>   response.renderString(template.asString(model.getObject()));
> }
>
> What am I doing wrong?
>
> P.S. I am using 1.5-rc2.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


-- 
Pedro Henrique Oliveira dos Santos


[MIGRATE 1.5] NPE trying to use JavaScriptTemplate

2011-04-22 Thread Alexandros Karypidis

Hi,

I've just started preparing for 1.5 and have been modifying my code in  
order to conform with the new API. I've managed to get my application to  
compile and launch, but in my first attempt to render a page I get an NPE  
as follows:


java.lang.NullPointerException
 at  
org.apache.wicket.util.template.TextTemplateDecorator.setLastModified(TextTemplateDecorator.java:195)
 at  
org.apache.wicket.util.resource.AbstractStringResourceStream.(AbstractStringResourceStream.java:76)
 at  
org.apache.wicket.util.resource.AbstractStringResourceStream.(AbstractStringResourceStream.java:62)
 at  
org.apache.wicket.util.template.TextTemplate.(TextTemplate.java:42)
 at  
org.apache.wicket.util.template.TextTemplateDecorator.(TextTemplateDecorator.java:52)
 at  
org.apache.wicket.util.template.JavaScriptTemplate.(JavaScriptTemplate.java:42)

 at assets.wicket.ovimaps.OviMap.renderHead(OviMap.java:46)
 at org.apache.wicket.Component.renderHead(Component.java:2644)

Now this part of the code is an adaptation of what used to be a  
template-based javascript header contribution as follows:


 add(TextTemplateHeaderContributor.forJavaScript(OviMap.class,  
"OviMap.js", model));


The above has been removed from the component constructor (where it used  
to be) and replaced with the following in code inside my component:


 @Override
 public void renderHead(IHeaderResponse response) {
  super.renderHead(response);
  JavaScriptTemplate template = new JavaScriptTemplate(
   new PackagedTextTemplate(OviMap.class, "OviMap.js"));
   response.renderString(template.asString(model.getObject()));
 }

What am I doing wrong?

P.S. I am using 1.5-rc2.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org