You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Marc Lustig <ma...@marclustig.com> on 2002/09/18 17:31:30 UTC
trouble extending TemplatePageAttributes
Hi again,
I extended TemplatePageAttributes with TemplatePageExtendedAttributes to include some new methods:
package de.geoconnect.audiotex.turbineext;
public class TemplatePageExtendedAttributes extends TemplatePageAttributes implements ApplicationTool
{
...
public TemplatePageAttributes setScript(String url)
{
data.getPage().getHead().addElement(new Script().setSrc(url)
.setType("text/javascript").setLanguage("JavaScript"));
return this;
}
}
... and modified the corresponding entry in TR.props:
tool.request.page=org.apache.turbine.util.template.TemplatePageExtendedAttributes
Now, when accessing my new method in my Default.vm template
$page.setScript("resources/audiotex.js")
I get the following error:
Horrible Exception: org.apache.velocity.exception.MethodInvocationException: Invocation of method 'setScript' in class de.geoconnect.audiotex.turbineext.TemplatePageExtendedAttributes threw exception class java.lang.NullPointerException : null
I have placed the file audiotex.js in webapps\resources.
What's wrong here?
I'm grateful for any hint.
Marc
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: AW: AW: trouble extending TemplatePageAttributes
Posted by Scott Eade <se...@backstagetech.com.au>.
> From: "Marc Lustig" <ma...@marclustig.com>
>
> When I don't use any of the methods of my TemplatePageExtendedAttributes
> class in my Default.vm everything works fine. When I include one of the
> methods like the setScript nothing appears except the error message.
> When I comment the one statement in setScript it works fine as well, but
> nothing is put into the head, of course.
> It seems the problem is due to the RunData-field not being initialized
> properly.
>
> Also, your patch appears incomplete since the RunData-field in
> TemplatePageAttributes is declared private. You need to add the field to the
> extended class in order to compile.
> I have to dig further...
I think I understand the problem now. You have to remember that the patch
was for TemplatePageAttributes itself. If you are implementing a class that
extends TemplatePageAttributes then there are a few extra things you need.
To make this easy for you I have attached my TamplatePageAttributesEx class
which I use with my turbine 2.1 based application.
Cheers,
Scott
--
Scott Eade
Backstage Technologies Pty. Ltd.
http://www.backstagetech.com.au
AW: AW: trouble extending TemplatePageAttributes
Posted by Marc Lustig <ma...@marclustig.com>.
> -----Ursprungliche Nachricht-----
> Von: Scott Eade [mailto:seade@backstagetech.com.au]
> Gesendet: Donnerstag, 19. September 2002 01:00
> An: turbine-user
> Betreff: Re: AW: trouble extending TemplatePageAttributes
>
>
> > From: "Marc Lustig" <ma...@marclustig.com>
> >
> > $page.setScript($content.getURI("resources/audiotex.js"))
> >
> This is how I use the setScript() method that I have added to my extended
> TemplatePageAttributes.
>
> Everything else looks okay, but I am wondering how your page renders when
> the template does not include the above line - in particular, does the
> rendered html include a <head> element?
When I don't use any of the methods of my TemplatePageExtendedAttributes
class in my Default.vm everything works fine. When I include one of the
methods like the setScript nothing appears except the error message.
When I comment the one statement in setScript it works fine as well, but
nothing is put into the head, of course.
It seems the problem is due to the RunData-field not being initialized
properly.
Also, your patch appears incomplete since the RunData-field in
TemplatePageAttributes is declared private. You need to add the field to the
extended class in order to compile.
I have to dig further...
Marc
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: AW: trouble extending TemplatePageAttributes
Posted by Scott Eade <se...@backstagetech.com.au>.
> From: "Marc Lustig" <ma...@marclustig.com>
>
> $page.setScript($content.getURI("resources/audiotex.js"))
>
This is how I use the setScript() method that I have added to my extended
TemplatePageAttributes.
Everything else looks okay, but I am wondering how your page renders when
the template does not include the above line - in particular, does the
rendered html include a <head> element?
The setScript() method I provided is pretty small. It shouldn't be too
difficult to add a few debugging statements to figure out where the problem
is coming from.
HTH,
Scott
--
Scott Eade
Backstage Technologies Pty. Ltd.
http://www.backstagetech.com.au
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
AW: trouble extending TemplatePageAttributes
Posted by Marc Lustig <ma...@marclustig.com>.
There was an error in my own posting from today:
of course the entry in TR.props is
tool.request.page=de.geoconnect.audiotex.turbineext.TemplatePageExtendedAttributes
and not
tool.request.page=org.apache.turbine.util.template.TemplatePageExtendedAttributes
And I also tried
$page.setScript($content.getURI("resources/audiotex.js"))
instead of
> $page.setScript("resources/audiotex.js")
but still get the same error:
> Horrible Exception:
> org.apache.velocity.exception.MethodInvocationException:
> Invocation of method 'setScript' in class
> de.geoconnect.audiotex.turbineext.TemplatePageExtendedAttributes
> threw exception class java.lang.NullPointerException : null
Anybody having a hint for me?
Thanks!
Marc
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>