You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by "Henning P. Schmiedehausen" <ma...@mail.hometree.net> on 2001/04/20 12:21:01 UTC

Using a non-template layout in a Velocity site (and a little rant about the TDK)

Hi,

I must admit, that I'm pretty new to Turbine and Velocity and probably
just overlooking lots of things. But I start getting a hang of this
stuff and it seems to turn out right in the direction that I wanted. ;-)

I'm using the "current" Turbine version (pulled from the CVS on 4/19/2001)
and experiment with template based stuff.

I'm using a velocity site test program which has 

page.default=VelocityPage

services.VelocityService.template.extension=vm
services.VelocityService.default.page = VelocityPage
services.VelocityService.default.screen=VelocityScreen
services.VelocityService.default.layout = VelocityECSLayout
services.VelocityService.default.navigation=VelocityNavigation
services.VelocityService.default.error.screen = VelocityErrorScreen
services.VelocityService.default.layout.template = /Default.vm

in its TurbineResources.properties

I need, however, a small change to the VelocityECSLayout (I'm aware of
the VelocityOnlyLayout layout class, but as I said, I'm toying
around): I need a "LINK" reference for a style sheet, soI wrote a
small helper class for my own personal layout, fun and profit: 

--- cut ---
package Im.dns.modules.layouts;

import org.apache.velocity.context.Context;

import org.apache.turbine.util.RunData;
import org.apache.turbine.modules.layouts.VelocityECSLayout;
import org.apache.turbine.util.ContentURI;

import org.apache.ecs.html.Link;
import org.apache.ecs.html.Style;

public class Test extends VelocityECSLayout
{
  protected void build(RunData data) throws Exception
  {
    data.getPage().getHead().addElement(
      new Link()
      .setRel("stylesheet")
      .setHref(new ContentURI(data).getURI("style/default.css"))
      .setType(Style.CSS));
    super.build(data);
  }

--- cut ---

If I put 

services.VelocityService.default.layout = Test

in my TR.props, this works fine. 

But if I try to do this in my Index.vm:

$data.setLayout("Test")

it does not work at all. As far as I can see, this is, because the
decision to use the VelocityECSTemplate for rendering the layout was
already made for me in o.a.t.modules.pages.DefaultPage (l. 164 ff):

--- cut ---
if ( layout != null )
{
    LayoutLoader.getInstance().exec ( data, layout );
}
else
{
    ScreenLoader.getInstance().exec ( data, data.getScreen() );
}

--- cut ---

the LayoutLoader fetches the VelocityECSLayout and it renders the
screen. I can change the Template because this is explictly used in
the VelocityECSLayout, but I cannot change the layout rendering class
itself, because at the time it comes to parsing the Velocity Page, the
decision was already made.

I understand that the calling sequence is 

page --> layout --> screen

so if I try to change the layout in the screen, it's already too late.

If I use Turbine without Velocity, I can set all the nice things like
pages, layouts and screens from my Java code. If I use Velocity, I
give all this stuff to the Velocity Rendering Classes:

services.VelocityService.default.page = VelocityPage
services.VelocityService.default.screen=VelocityScreen
services.VelocityService.default.layout = VelocityECSLayout
services.VelocityService.default.navigation=VelocityNavigation

If I don't want to be stuck with the default values, I have to have a
corresponding class to all my non-template-layout rendered screens
that does

public class Index extends VelocityScreen
{
  public String getLayout(RunData data)
  {
    return "Test";
  }
}

(I tried 

  public doBuildTemplate(RunData data, Context ctx)
  {
    data.setLayout("Test");
  }

also but I got shot down by the fact that the Layout is again pulled
from the screen before the doBuildTemplate is called.

)

So, am I right that, for moving away from the Template-Based
(VelocityPage/VelocityECSLayout/VelocityScreen) rendering, I must have
a class for each screen? That I can not do this with templates alone?

And BTW: How do I put a line in the Header like the following in the header of a HTML page 

<link href="/<application>/style/default.css" type="text/css" rel="stylesheet">

inside a template without resorting to
$data.getHead.addElement("<hardcoded line>")? 

Because this is the problem in the first place. ;-)

Oh, yes, I tried the TDK first, but franky, the number of things to
look at is simply to overwhelming (Turbine, Velocity, Torque, Texen,
Village, Intake-Service, Anakia to name just a few that crossed my
mind). Ok, if you have six weeks time to toy with this and half a year
to get experience, TDK is the right way to start. And a cool way,
too. But without documentation (e.g. intake: "The only documentation
is in the Scarab source". Ugh. How to get the scarab source? It's in
an CVS server somewhere (if you go to scarab.tigris.org, you'll find
some outdated links which may or may not lead to the right
places... =:-) )

Oh yes, I'd really like to contribute to the documentation. But no way
that I learn five new undocumented tools just to contribute, because
the docs are in xdocs somewhere and transformed. Where is a "how to
contribute to the documentation" documentation? :-)

The TDK is IMHO more of a technology demo than a really useful
devlopment kit. Lots and lots of tools (which are helpful for turbine
but not really necessary) to confuse the newcomer.

Just using the turbine.jar and adding others as you go proved at least
for me, much more helpful. I'm thinking about preparing some notes
about this as a "Turbine without TDK" tutorial. 

	Regards
		Henning

-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen       -- Geschaeftsfuehrer
INTERMETA - Gesellschaft fuer Mehrwertdienste mbH     hps@intermeta.de

Am Schwabachgrund 22  Fon.: 09131 / 50654-0   info@intermeta.de
D-91054 Buckenhof     Fax.: 09131 / 50654-20   

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: Using a non-template layout in a Velocity site (and a little

Posted by Jon Stevens <jo...@latchkey.com>.
on 4/21/01 4:14 AM, "Henning P. Schmiedehausen" <ma...@mail.hometree.net>
wrote:

> I would have preferred, however if you could have helped me with the
> technical part of my first mail. :-)
> 
> Regards
> Henning

And I would have appreciated it if you would have figured out the technical
part on your own (this stuff isn't rocket science) and sent us documentation
or patches so that the next person who runs into the problem could have an
easier time.

:-)

Do you see the difference? My job isn't to help you, my job is to produce
cool solutions and share them with the rest of the world who can choose to
either work with those solutions or re-invent them on their own. You can
also choose to help out with this group effort or sit back and whine about
people not helping you out.

:-)

-jon


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: Using a non-template layout in a Velocity site (and a little

Posted by "Henning P. Schmiedehausen" <ma...@mail.hometree.net>.
Jon Stevens <jo...@latchkey.com> writes:

>on 4/20/01 2:15 PM, "Henning P. Schmiedehausen" <ma...@mail.hometree.net>
>wrote:

>> If I write a tutorial for Turbine in HTML, what would be your
>> reaction? "Cool" or "Do it again in XML"?
>> 
>> Regards
>> Henning

>It would be both.

>"Cool and Do it again in XML"

--- cut ---
What that boils down to is, if you see something wrong and do nothing
about it, the opensource system hasnt failed you, *you* have failed
the opensource system.
--- cut ---

"So if your're missing a needed format in this project and you do
nothing about it, it is your own fault for not getting off your lazy
arse and taking advantage of the participation opensource allows." [I
was free to change a few words from the paragraph on your quoted
URL. :-) ]

I would have preferred, however if you could have helped me with the
technical part of my first mail. :-)

	Regards
		Henning

-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen       -- Geschaeftsfuehrer
INTERMETA - Gesellschaft fuer Mehrwertdienste mbH     hps@intermeta.de

Am Schwabachgrund 22  Fon.: 09131 / 50654-0   info@intermeta.de
D-91054 Buckenhof     Fax.: 09131 / 50654-20   

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: Using a non-template layout in a Velocity site (and a little

Posted by Jon Stevens <jo...@latchkey.com>.
on 4/20/01 2:15 PM, "Henning P. Schmiedehausen" <ma...@mail.hometree.net>
wrote:

> If I write a tutorial for Turbine in HTML, what would be your
> reaction? "Cool" or "Do it again in XML"?
> 
> Regards
> Henning

It would be both.

"Cool and Do it again in XML"

Part of working in OSS is following the rules and procedures of the overall
project. It is a group/team effort, not an individual going out and making
up their own rules. Otherwise there would be constant chaos and nothing
would get done.

Sure, there is a lot of individual personalities that make up the team, I'm
probably the one with the loudest and most direct personality. However, I'm
clearly here for the group effort and I think that stands out the most over
the nits that people have with my approach.

So, go ahead and post your little "rants" as they really don't do anything
to help anyone except make yourself feel better.

:-)

thanks,

-jon


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: Using a non-template layout in a Velocity site (and a little

Posted by "Henning P. Schmiedehausen" <ma...@mail.hometree.net>.
Jon Stevens <jo...@latchkey.com> writes:

>You are also clearly new to Open Source.

No. Definitely not. Maybe new to the Jakarta effort but definitely
_not_ new to open source.

><http://jakarta.apache.org/site/understandingopensource.html>

But then again at least last week, I witnessed some of the "powers
that be" pissing off someone that _wanted_ to help by telling "do it
either our way or get lost". At least that was what it sounded to me.

If I write a tutorial for Turbine in HTML, what would be your
reaction? "Cool" or "Do it again in XML"?

	Regards
		Henning


-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen       -- Geschaeftsfuehrer
INTERMETA - Gesellschaft fuer Mehrwertdienste mbH     hps@intermeta.de

Am Schwabachgrund 22  Fon.: 09131 / 50654-0   info@intermeta.de
D-91054 Buckenhof     Fax.: 09131 / 50654-20   

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: Using a non-template layout in a Velocity site (and a little rant about the TDK)

Posted by Jon Stevens <jo...@latchkey.com>.
on 4/20/01 3:21 AM, "Henning P. Schmiedehausen" <ma...@mail.hometree.net>
wrote:

> 
> Oh, yes, I tried the TDK first, but franky, the number of things to
> look at is simply to overwhelming (Turbine, Velocity, Torque, Texen,
> Village, Intake-Service, Anakia to name just a few that crossed my
> mind). Ok, if you have six weeks time to toy with this and half a year
> to get experience, TDK is the right way to start. And a cool way,
> too. But without documentation (e.g. intake: "The only documentation
> is in the Scarab source". Ugh. How to get the scarab source? It's in
> an CVS server somewhere (if you go to scarab.tigris.org, you'll find
> some outdated links which may or may not lead to the right
> places... =:-) )
> 
> Oh yes, I'd really like to contribute to the documentation. But no way
> that I learn five new undocumented tools just to contribute, because
> the docs are in xdocs somewhere and transformed. Where is a "how to
> contribute to the documentation" documentation? :-)
> 
> The TDK is IMHO more of a technology demo than a really useful
> devlopment kit. Lots and lots of tools (which are helpful for turbine
> but not really necessary) to confuse the newcomer.
> 
> Just using the turbine.jar and adding others as you go proved at least
> for me, much more helpful. I'm thinking about preparing some notes
> about this as a "Turbine without TDK" tutorial.
> 
> Regards
> Henning

You are also clearly new to Open Source.

<http://jakarta.apache.org/site/understandingopensource.html>

-jon

-- 
If you come from a Perl or PHP background, JSP is a way to take
your pain to new levels. --Anonymous
<http://jakarta.apache.org/velocity/ymtd/ymtd.html>


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org