You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by David Wynter <da...@btclick.com> on 2002/04/16 13:27:48 UTC

Using VelocityOnlyLayout is there a way to setTitle?

When using VelocityOnlyLayout is there a way to set the title from the
screen template? I used to use $page.setTitle("title unique to screen") in
my screen template but this is only posssible when using VelocityECSLayout.
Now that the title is set in the Default.vm in the layout sub directory
specific to the role of the user eg. ..../app/layout/Admin/Default.vm I need
a way to recognise which screen is being used and to somehow get a title
associated with that screen. Has anybody done this before?


David Wynter
Director
roamware Ltd.
(+44) (0) 208 922 7539 B.
(+44) (0) 7879 605 706 M.
david@roamware.com


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


RE: Using VelocityOnlyLayout is there a way to setTitle?

Posted by David Wynter <da...@btclick.com>.
Yes I am creating the page from a Default.java that is common to all my
screens regardless of which sub directory they are in. I am using a pull
tool for all requirements unique to a particular screen.

I suppose I could use the Context in the Default.java to find the template
being used and have a look-up to match that against the title. Or I could
put the title into the Context, but not sure when I have access to the
Context to do this prior to the screen being displayed for the first time?

David

-----Original Message-----
From: Matthew Koranda [mailto:matt@orkan.no]
Sent: 16 April 2002 13:14
To: Turbine Users List
Subject: Re: Using VelocityOnlyLayout is there a way to setTitle?


Just off the top of my head, couldn't you use <title>$myTitle</title> and
then set myTitle in the .java file. Is this how you are creating the page?

HTH
Matt



----- Original Message -----
From: "David Wynter" <da...@btclick.com>
To: "Turbine-User" <tu...@jakarta.apache.org>
Sent: Tuesday, April 16, 2002 1:27 PM
Subject: Using VelocityOnlyLayout is there a way to setTitle?


> When using VelocityOnlyLayout is there a way to set the title from the
> screen template? I used to use $page.setTitle("title unique to screen") in
> my screen template but this is only posssible when using
VelocityECSLayout.
> Now that the title is set in the Default.vm in the layout sub directory
> specific to the role of the user eg. ..../app/layout/Admin/Default.vm I
need
> a way to recognise which screen is being used and to somehow get a title
> associated with that screen. Has anybody done this before?
>
>
> David Wynter
> Director
> roamware Ltd.
> (+44) (0) 208 922 7539 B.
> (+44) (0) 7879 605 706 M.
> david@roamware.com
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


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


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


Re: Using VelocityOnlyLayout is there a way to setTitle?

Posted by Matthew Koranda <ma...@orkan.no>.
Just off the top of my head, couldn't you use <title>$myTitle</title> and
then set myTitle in the .java file. Is this how you are creating the page?

HTH
Matt



----- Original Message -----
From: "David Wynter" <da...@btclick.com>
To: "Turbine-User" <tu...@jakarta.apache.org>
Sent: Tuesday, April 16, 2002 1:27 PM
Subject: Using VelocityOnlyLayout is there a way to setTitle?


> When using VelocityOnlyLayout is there a way to set the title from the
> screen template? I used to use $page.setTitle("title unique to screen") in
> my screen template but this is only posssible when using
VelocityECSLayout.
> Now that the title is set in the Default.vm in the layout sub directory
> specific to the role of the user eg. ..../app/layout/Admin/Default.vm I
need
> a way to recognise which screen is being used and to somehow get a title
> associated with that screen. Has anybody done this before?
>
>
> David Wynter
> Director
> roamware Ltd.
> (+44) (0) 208 922 7539 B.
> (+44) (0) 7879 605 706 M.
> david@roamware.com
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


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


Re: Using VelocityOnlyLayout is there a way to setTitle?

Posted by Eric Dobbs <er...@dobbse.net>.
On Tuesday, April 16, 2002, at 11:57  AM, John McNally wrote:

> David Wynter wrote:
>> I suppose I could add the titles specific to the screens in the 
>> properties
>> file too, but it is not as compact as this as there are few roles in 
>> the
>> system and quite a lot more screens.
>
> This is what we did in scarab, which uses t3.  Some sort of meta-data
> outside the screen template is needed, at least I have not come up with
> a better solution.

The Perl module HTML::Mason has an interesting solution.  Their 
equivalent of the screen/template can set template properties.  The 
equivalent of the layout can read those properties before rendering the 
content of the template.  I  like that usage.  It lets you keep the 
"meta-data" in the template.

I don't know enough about the internals of Velocity to know if this 
would be possible, but if the template could set a property in the 
context and the layout could get a handle on that context before 
velocity renders the template, then the same sort of usage could be 
employed here.

-Eric

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


Re: Using VelocityOnlyLayout is there a way to setTitle?

Posted by John McNally <jm...@collab.net>.
David Wynter wrote:
> 
> Eric,
> 
...
> I suppose I could add the titles specific to the screens in the properties
> file too, but it is not as compact as this as there are few roles in the
> system and quite a lot more screens.
> 

This is what we did in scarab, which uses t3.  Some sort of meta-data
outside the screen template is needed, at least I have not come up with
a better solution.

john mcnally

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


RE: Using VelocityOnlyLayout is there a way to setTitle?

Posted by David Wynter <da...@btclick.com>.
Eric,

I had thought about the idea of using a pull tool to somehow extract the
screen template I was using and have a lookup for the title that goes with
it, but not very elegant.

I have added these to my own application properties file.

# -------------------------------------------------------------------
#
#  The roles of the users of rwTransformer are shown here
#  These are as found in the Turbine_Role table
#  They are used to select the layout used
#  The roles.directory values must follow the same ordering of roles
#  property values
#  The values represent the directories under which actions and
#  screens the different roles are allowed access to.
# -------------------------------------------------------------------
roles=Administrator, Extract User, Message User
role.directory=Admin, ExtractUser, MsgUser


# -------------------------------------------------------------------
#
#  The layouts used for the different user roles
#  Property values must be in the same order as the roles above
# -------------------------------------------------------------------
role.layout=/Admin/Default.vm, /ExtractUser/Default.vm, /MsgUser/Default.vm

These are used by my SecureAction and SecureScreen implemetations to
determine the layouts based on role and directories specific to the roles.

I suppose I could add the titles specific to the screens in the properties
file too, but it is not as compact as this as there are few roles in the
system and quite a lot more screens.

regards

David

-----Original Message-----
From: Eric Dobbs [mailto:eric@dobbse.net]
Sent: 16 April 2002 18:26
To: Turbine Users List
Subject: Re: Using VelocityOnlyLayout is there a way to setTitle?


On Tuesday, April 16, 2002, at 10:42  AM, David Wynter wrote:

> You are missing the point. I have one layout template,
> .../app/layouts/Admin/Default.vm, for 12 screen classes. This enforces
> consistency of look and feel for a given role (Admin) using the system.
> Having $page.setTitle(..) was very powerful in this context. I see
> having to
> create 12 identical layouts with different names and one difference,
> that is
> title, as being poor architecture.

Now I get it.  I think this use case was part of the
ECS debate you mentioned.  As you've discovered, you
can only do that with ECS in the picture.  I know
you have returned to ECS, but for the sake of the
discussion I want to brainstorm some alternatives.

The first one that leaps to mind is to create a pull
tool for the common elements in your layout, instead
of using the layout.  So your screen templates could
use something like this:
$header.renderWithTitle("unique title for this page")

Of course, this doesn't cleanly separate the layout
from the screen:
<table>
<tr><td colspan="2">$header.renderFoo()</td><tr>
<tr><td>$leftBar.renderFoo()<td>
<td>
<!-- your screen goes here -->
</td>
</tr>
</table>

In Turbine 3, I understand the the pipeline is thought
to enable something of this nature, but I haven't even
looked at it, so I can't say how that will work.

-Eric

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


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


Re: Using VelocityOnlyLayout is there a way to setTitle?

Posted by Eric Dobbs <er...@dobbse.net>.
On Tuesday, April 16, 2002, at 10:42  AM, David Wynter wrote:

> You are missing the point. I have one layout template,
> .../app/layouts/Admin/Default.vm, for 12 screen classes. This enforces
> consistency of look and feel for a given role (Admin) using the system.
> Having $page.setTitle(..) was very powerful in this context. I see 
> having to
> create 12 identical layouts with different names and one difference, 
> that is
> title, as being poor architecture.

Now I get it.  I think this use case was part of the
ECS debate you mentioned.  As you've discovered, you
can only do that with ECS in the picture.  I know
you have returned to ECS, but for the sake of the
discussion I want to brainstorm some alternatives.

The first one that leaps to mind is to create a pull
tool for the common elements in your layout, instead
of using the layout.  So your screen templates could
use something like this:
$header.renderWithTitle("unique title for this page")

Of course, this doesn't cleanly separate the layout
from the screen:
<table>
<tr><td colspan="2">$header.renderFoo()</td><tr>
<tr><td>$leftBar.renderFoo()<td>
<td>
<!-- your screen goes here -->
</td>
</tr>
</table>

In Turbine 3, I understand the the pipeline is thought
to enable something of this nature, but I haven't even
looked at it, so I can't say how that will work.

-Eric

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


RE: Using VelocityOnlyLayout is there a way to setTitle?

Posted by David Wynter <da...@btclick.com>.
Eric,

You are missing the point. I have one layout template,
.../app/layouts/Admin/Default.vm, for 12 screen classes. This enforces
consistency of look and feel for a given role (Admin) using the system.
Having $page.setTitle(..) was very powerful in this context. I see having to
create 12 identical layouts with different names and one difference, that is
title, as being poor architecture.

I have reverted to VelocityECSLayout by solving the problem with not finding
my JavaScript file (don't ask) by extending TemplatePageAttributes to have a
method that allows me to setScript(...) and I am happily using
VelocityECSLayout again after a brief but painful foray into
VelocityOnlyLayout.


Thanks for the suggestion though.

David
-----Original Message-----
From: Eric Dobbs [mailto:eric@dobbse.net]
Sent: 16 April 2002 17:35
To: Turbine Users List
Subject: Re: Using VelocityOnlyLayout is there a way to setTitle?



On Tuesday, April 16, 2002, at 05:27  AM, David Wynter wrote:

> When using VelocityOnlyLayout is there a way to set the title from the
> screen template? I used to use $page.setTitle("title unique to screen")
> in
> my screen template but this is only posssible when using
> VelocityECSLayout.
> Now that the title is set in the Default.vm in the layout sub directory
> specific to the role of the user eg. ..../app/layout/Admin/Default.vm I
> need
> a way to recognise which screen is being used and to somehow get a title
> associated with that screen. Has anybody done this before?

Is there some reason that just using the HTML isn't working?

In the VelocityLayout, you don't get to use HTML to control
anything outside the <body> tags.  So you have to use $page
in order to set a title.  Part of what's interesting about
VelocityOnlyLayout is that you get to include the rest of the
HTML.

try this at the top of your .vm:
<html>
<head><title>title unique to screen</title></head>
<body>

Hope that helps.
-Eric

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


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


Re: Using VelocityOnlyLayout is there a way to setTitle?

Posted by Eric Dobbs <er...@dobbse.net>.
On Tuesday, April 16, 2002, at 05:27  AM, David Wynter wrote:

> When using VelocityOnlyLayout is there a way to set the title from the
> screen template? I used to use $page.setTitle("title unique to screen") 
> in
> my screen template but this is only posssible when using 
> VelocityECSLayout.
> Now that the title is set in the Default.vm in the layout sub directory
> specific to the role of the user eg. ..../app/layout/Admin/Default.vm I 
> need
> a way to recognise which screen is being used and to somehow get a title
> associated with that screen. Has anybody done this before?

Is there some reason that just using the HTML isn't working?

In the VelocityLayout, you don't get to use HTML to control
anything outside the <body> tags.  So you have to use $page
in order to set a title.  Part of what's interesting about
VelocityOnlyLayout is that you get to include the rest of the
HTML.

try this at the top of your .vm:
<html>
<head><title>title unique to screen</title></head>
<body>

Hope that helps.
-Eric

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