You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Godwin Ko <go...@hotmail.com> on 2002/05/15 13:37:48 UTC

Can't display template with no corresponding class file

Hi all,

I'm using tdk 2.1 and I can't display a template file which don't need velocity context, i.e. a static page with no corresponding java class file existed.  Turbine always return that default login page and if I create a dummy java class file just extend from VelocityScreen but with no code at all, then it works as expected.  The behaviour doesn't match with the Velocity Site Howto guide.  Can anyone tell me what I have done wrong?

Thanks,
Godwin Ko.

Re: Can't display template with no corresponding class file

Posted by Mark Nutter <ma...@zoominternet.net>.
On Wed, 2002-05-15 at 14:36, Mark Nutter wrote:
> On Wed, 2002-05-15 at 11:14, Godwin Ko wrote:
> > If I create a screen class named Default.java at the top screen level then
> > all template files that with no screen class defined will use this default
> > screen class, is this the default behavior of turbine 2.1?  I'm a little bit
> > confuse about the java screen binding with template.  The template search
> > sequence has been documented in Velocity Site howto but is the screen class
> > search sequence the same as template?

Did some more digging :)  According to the Javadoc for
org.apache.turbine.modules.pages.DefaultPage, the answer is Yes, the
search for a screen class the same way it searches for a Velocity
template.  Turbine looks for a screen class with the same name as the
screen template (except that the first letter of the class name is
forced to uppercase, and with .class instead of .vm), in the directory
parallel to the directory/path of the screen, i.e. if the screen is in

.../templates/com/mysite/myapp/modules/screens/pub/MyScreen.vm

then the corresponding screen class would be in 

.../classes/com/mysite/myapp/modules/screens/pub/MyScreen.class

Or it might be

.../classes/com/mysite/myapp/modules/screens/pub/Myscreen.class
                                      lower case!--^

I'm not sure how the capitalization works.  Anyway, if it doesn't find
the class where it expects to, it looks for a class named Default.class,
starting in the directory where the screen class should have been, and
working its way up.  One wrinkle is that the search path includes all
paths listed in the "module.packages" line of TR.props, so if your
TR.props file has

module.packages=com/mysite/myapp/modules,org/apache/turbine/flux/modules

then the search will go like this:

.../classes/com/mysite/myapp/modules/screens/pub/Default.class
.../classes/com/mysite/myapp/modules/screens/Default.class
.../classes/org/apache/turbine/flux/modules/screens/pub/Default.class
.../classes/org/apache/turbine/flux/modules/screens/Default.class

I did some testing, writing some Default classes that put the
fully-qualified default class name into the Velocity context as
$MyScreen, and then modifying my templates to print out $MyScreen. 
Under TDK/Turbine 2.1, it works as advertised on my system.  I thought I
had a situation where the Default.class was overriding my Index.class
for Index.vm, but apparently that was a fluke.  It must not have been
finding my Index.class file for some reason, not sure why, but it went
away on a rebuild/restart.

HTH.

Mark

manutter@zoominternet.net
My horoscope says today is a bad day to be superstitious.



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Can't display template with no corresponding class file

Posted by Mark Nutter <ma...@zoominternet.net>.
On Wed, 2002-05-15 at 11:14, Godwin Ko wrote:
> If I create a screen class named Default.java at the top screen level then
> all template files that with no screen class defined will use this default
> screen class, is this the default behavior of turbine 2.1?  I'm a little bit
> confuse about the java screen binding with template.  The template search
> sequence has been documented in Velocity Site howto but is the screen class
> search sequence the same as template?
> 
> Godwin Ko.

I'm also tinkering with tdk/turbine 2.1 trying to understand how it all
works.  I don't feel like I understand it quite well enough to try and
give you a definitive answer, but one thing I've found helpful is that
Turbine looks for classes in much the same way as Java searches the
CLASSPATH.  If your TurbineResources.properties file specifies
module.packages=<my.packages.path>,org.apache.turbine.flux.modules, then
turbine will search in my/packages/path for class files before searching
in the org/apache/turbine/... path.

What I did was to copy the standard VelocityPage and VelocityECSLayout
from the org/apache directories into my own directory tree, renamed to
MyVelocityPage.java and MyVelocityECSLayout.java.  Then I modified the
TR.props file to point to MyVelocityPage and MyVelocityECSLayout instead
of the originals.  A few System.out.println's, and I could watch the
program code scroll by as my web pages loaded.

For some reason, all my screens seem to wind up calling
FluxScreen.isAuthorized() at some point--not sure why.  But anyway,
maybe this will help you trace your own code.  Turbine is a bit tricky
to follow if you're trying to step through the code by eyeballing it.

Mark

manutter@zoominternet.net
My horoscope says today is a bad day to be superstitious.



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Can't display template with no corresponding class file

Posted by Godwin Ko <go...@hotmail.com>.
If I create a screen class named Default.java at the top screen level then
all template files that with no screen class defined will use this default
screen class, is this the default behavior of turbine 2.1?  I'm a little bit
confuse about the java screen binding with template.  The template search
sequence has been documented in Velocity Site howto but is the screen class
search sequence the same as template?

Godwin Ko.

----- Original Message -----
From: "Godwin Ko" <go...@hotmail.com>
To: <tu...@jakarta.apache.org>
Sent: Wednesday, May 15, 2002 7:37 PM
Subject: Can't display template with no corresponding class file


Hi all,

I'm using tdk 2.1 and I can't display a template file which don't need
velocity context, i.e. a static page with no corresponding java class file
existed.  Turbine always return that default login page and if I create a
dummy java class file just extend from VelocityScreen but with no code at
all, then it works as expected.  The behaviour doesn't match with the
Velocity Site Howto guide.  Can anyone tell me what I have done wrong?

Thanks,
Godwin Ko.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>