You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Mathias Bogaert <mb...@transwide.com> on 2002/06/04 10:46:43 UTC

velocity-tools and pageContext

Hi,

I'm currently evaluating how add Velocity support to SiteMesh (
www.opensymphony.com/sitemesh ), but I 
need a way to obtain the pageContext from the ViewContext. How can I do
this?

Thanks,

Mathias Bogaert

PS reply to pathos@pandora.be please

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


Re: velocity-tools and pageContext

Posted by Bill Burton <bi...@progress.com>.
Hello Mathias,

Mathias Bogaert wrote:
> 
> Hi Bill,
> 
> For one, I found that I don't need the pageContext after all. But for
> SiteMesh to
> support Velocity, at first sight (I am a total Velocity newbe), SiteMesh
> needs to undergo
> a fair amount of refactoring.
> 
> > Could you explain in more detail what you are trying to do?  Is this to
> > add support to Sitemesh so decorators can be implemented in Velocity as
> > well as JSP?
> 
> Here is the way we see it:
> http://jira.opensymphony.com/ViewIssue.jspa?id=10126 (feel free to comment!)
> So yes, decorators can be implemented in Velocity as well as JSP. The only
> big
> difference is that Velocity is a servlet, and SiteMesh a filter that closely
> works together
> with the jsp though taglibs, and with the request and response to put data
> into.

Although Velocity is often called from a servlet, there's no requirement
to do so.  It can be called from any kind of Java application including a
servlet filter.  In that case, you won't be able to extend the
VelocityServlet class but you could use that class as a starting point to
create something that will work within a servlet filter.

-Bill

> This definatily needs more investigation from my part, so stay tuned :)
> 
> Mathias
> 
> ----- Original Message -----
> From: "Bill Burton" <bi...@progress.com>
> To: <pa...@pandora.be>
> Cc: "Velocity Users List" <ve...@jakarta.apache.org>
> Sent: Tuesday, June 04, 2002 9:43 AM
> Subject: Re: velocity-tools and pageContext
> 
> > Hello Mathias,
> >
> > Mathias Bogaert wrote:
> > >
> > > Hi,
> > >
> > > I'm currently evaluating how add Velocity support to SiteMesh (
> > > www.opensymphony.com/sitemesh ),
> >
> > That would be great!  There have been a number of people on this list
> > asking how to do templating in Velocity for a common look and feel.
> > Sitemesh is the best solution I've seen for this kind of thing.  It would
> > be great to have better integration with Velocity.
> >
> > I while ago, I borrowed the Sitemesh FastPageParser and implemented a
> > simple way to skin any Velocity template with another Velocity template in
> > the same manner as a Sitemesh decorator.  With this approach, the Servlet
> > 2.3 API wasn't needed because Velocity.evaluate() was being called.  This
> > implementation was just a prototype so it didn't have the flexibility you
> > have with the Sitemesh XML configuration file and the only thing that
> > could be skinned was Velocity templates.
> >
> > > but I need a way to obtain the pageContext from the ViewContext. How can
> I do
> > > this?
> >
> > Could you explain in more detail what you are trying to do?  Is this to
> > add support to Sitemesh so decorators can be implemented in Velocity as
> > well as JSP?
> >
> > -Bill
> >
> > > Thanks,
> > >
> > > Mathias Bogaert
> > >
> > > PS reply to pathos@pandora.be please
> >

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


Re: velocity-tools and pageContext

Posted by Mathias Bogaert <pa...@pandora.be>.
Hi Bill,

For one, I found that I don't need the pageContext after all. But for
SiteMesh to
support Velocity, at first sight (I am a total Velocity newbe), SiteMesh
needs to undergo
a fair amount of refactoring.

> Could you explain in more detail what you are trying to do?  Is this to
> add support to Sitemesh so decorators can be implemented in Velocity as
> well as JSP?

Here is the way we see it:
http://jira.opensymphony.com/ViewIssue.jspa?id=10126 (feel free to comment!)
So yes, decorators can be implemented in Velocity as well as JSP. The only
big
difference is that Velocity is a servlet, and SiteMesh a filter that closely
works together
with the jsp though taglibs, and with the request and response to put data
into.

This definatily needs more investigation from my part, so stay tuned :)

Mathias

----- Original Message -----
From: "Bill Burton" <bi...@progress.com>
To: <pa...@pandora.be>
Cc: "Velocity Users List" <ve...@jakarta.apache.org>
Sent: Tuesday, June 04, 2002 9:43 AM
Subject: Re: velocity-tools and pageContext


> Hello Mathias,
>
> Mathias Bogaert wrote:
> >
> > Hi,
> >
> > I'm currently evaluating how add Velocity support to SiteMesh (
> > www.opensymphony.com/sitemesh ),
>
> That would be great!  There have been a number of people on this list
> asking how to do templating in Velocity for a common look and feel.
> Sitemesh is the best solution I've seen for this kind of thing.  It would
> be great to have better integration with Velocity.
>
> I while ago, I borrowed the Sitemesh FastPageParser and implemented a
> simple way to skin any Velocity template with another Velocity template in
> the same manner as a Sitemesh decorator.  With this approach, the Servlet
> 2.3 API wasn't needed because Velocity.evaluate() was being called.  This
> implementation was just a prototype so it didn't have the flexibility you
> have with the Sitemesh XML configuration file and the only thing that
> could be skinned was Velocity templates.
>
> > but I need a way to obtain the pageContext from the ViewContext. How can
I do
> > this?
>
> Could you explain in more detail what you are trying to do?  Is this to
> add support to Sitemesh so decorators can be implemented in Velocity as
> well as JSP?
>
> -Bill
>
> > Thanks,
> >
> > Mathias Bogaert
> >
> > PS reply to pathos@pandora.be please
>


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


Re: velocity-tools and pageContext

Posted by Bill Burton <bi...@progress.com>.
Hello Mathias,

Mathias Bogaert wrote:
> 
> Hi,
> 
> I'm currently evaluating how add Velocity support to SiteMesh (
> www.opensymphony.com/sitemesh ),

That would be great!  There have been a number of people on this list
asking how to do templating in Velocity for a common look and feel. 
Sitemesh is the best solution I've seen for this kind of thing.  It would
be great to have better integration with Velocity.  

I while ago, I borrowed the Sitemesh FastPageParser and implemented a
simple way to skin any Velocity template with another Velocity template in
the same manner as a Sitemesh decorator.  With this approach, the Servlet
2.3 API wasn't needed because Velocity.evaluate() was being called.  This
implementation was just a prototype so it didn't have the flexibility you
have with the Sitemesh XML configuration file and the only thing that
could be skinned was Velocity templates.  

> but I need a way to obtain the pageContext from the ViewContext. How can I do
> this?

Could you explain in more detail what you are trying to do?  Is this to
add support to Sitemesh so decorators can be implemented in Velocity as
well as JSP? 

-Bill

> Thanks,
> 
> Mathias Bogaert
> 
> PS reply to pathos@pandora.be please

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


Re: velocity-tools and pageContext

Posted by Gabriel Sidler <si...@teamup.ch>.
Geir Magnusson Jr. wrote:

> On 6/4/02 6:18 AM, "Gabriel Sidler" <si...@teamup.ch> wrote:
> 
> 
>>Mathias Bogaert wrote:
>>
>>
>>>Hi,
>>>
>>>I'm currently evaluating how add Velocity support to SiteMesh (
>>>www.opensymphony.com/sitemesh ), but I
>>>need a way to obtain the pageContext from the ViewContext. How can I do
>>>this?
>>>
>>>Thanks,
>>>
>>>Mathias Bogaert
>>>
>>>PS reply to pathos@pandora.be please
>>>
>>
>>Mathias,
>>as far as I understand things, page context is a concept that is
>>introduced by JSP. If you use a different view technology than
>>JSP there is no page context. You would have to implemement it
>>yourself.
>>I am actually wondering if and how people have solved this in
>>Velocity. In all my past Velocity/WebMacro apps I never had a
>>need for a page context.
>>
> 
> You need the pageContext in JSP because that's the internal API used for
> tags, right?  So if you want the writer to do output, you need the page
> context.
> 
> There is a context in velocity, and internally, in the directives and such,
> we have our own pageContext-ish kind of thing, but that's really for
> internal use.
> 
> Why would you need the pageContext?  You want to use Velocity within a JSP?


Sorry, I wasn't very precise. You are right that PageContext provides many
methods that are not relevant outside a JSP environment (convenience methods,
life cycle methods, etc.). The one (potentially) interesting feature that I
meant to refer to was that PageContext provides is a page scope, i.e. the
ability to associate state with a particular page. That state persists over
the lifetime of that page, which is typically the runtime of the application.
So, in addition to request state, session state, application state there is
also a page state. I don't think there is anything equivalent in Velocity.

I personally never had a need to associated state with a particular page but
I can see that this might be useful in model 1 applications where a JSP page
serves as the controller. My guess was that Mathias was refering to this.
Mathias, can you explain why you need access to the pageContext from Velocity
templates?

Gabe




--
Gabriel Sidler
Software Engineer, Eivycom GmbH, Zurich, Switzerland


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


RE: Can I get a Velocity version for Java 1.18

Posted by Paulo Gaspar <pa...@krankikom.de>.
I think that the rt.jar way could get you into seriously trouble.

As mentioned before, there is a collections.zip file that backports
the collections API to JDK 1.1. Some URLs:
- To download it:
  http://java.sun.com/products/javabeans/infobus/#DOWNLOAD_COLLECTIONS

- To know what it is:
  http://java.sun.com/products/javabeans/infobus/collectionsreadme.html


Have fun,
Paulo Gaspar

> -----Original Message-----
> From: Will Glass-Husain [mailto:wglass@forio.com]
> Sent: Thursday, June 06, 2002 8:33 PM
> To: Velocity Users List
> Subject: RE: Can I get a Velocity version for Java 1.18
>
>
> Hi,
>
> > You mean that I would, for instance, provide my own java.util.HashMap,
> > and other java 1.2 classes that Velocity needs?
>
> Couldn't you just put the JDK 1.2 "rt.jar" file in your classpath?  That
> contains the collection classes.  You could run the 1.1 JVM, but
> use the 1.2
> rt.jar.
>
> There might be licensing issues with this.  You're probably ok if
> you don't
> redistribute the incomplete JDK.  (which may or may not be useful).
>
> WILL
>
> -----Original Message-----
> From: Joaquim Carvalho [mailto:jrc@bookmarc.pt]
> Sent: Tuesday, June 04, 2002 8:49 AM
> To: Velocity Users List
> Subject: Re: Can I get a Velocity version for Java 1.18
>
>
>
> On Tuesday, June 4, 2002, at 01:10 PM, Geir Magnusson Jr. wrote:
>
> >> For some reason I though 0.75 was good for java 1.18 but obviously I am
> >> wrong.
> >>
> >> Any solution other than goind through the Velocity code and replace the
> >> collections classes with references to the ones Sun supplies in
> >> collections.zip?
> >>
> >
> > Yuck.  That would be painful and you would then be stuck with that
> > version.
> >
> > Is it possible to have a set of wrapper classes for backwards
> > compatibility?
> > I naively think this should be possible, at least for the basic stuff
> > like
> > collections?
> >
>
> You mean that I would, for instance, provide my own java.util.HashMap,
> and other java 1.2 classes that Velocity needs?
> I suppose I can do that.
>
> Joaquim
>
>
> --
> 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: Can I get a Velocity version for Java 1.18

Posted by Will Glass-Husain <wg...@forio.com>.
Hi,

> You mean that I would, for instance, provide my own java.util.HashMap,
> and other java 1.2 classes that Velocity needs?

Couldn't you just put the JDK 1.2 "rt.jar" file in your classpath?  That
contains the collection classes.  You could run the 1.1 JVM, but use the 1.2
rt.jar.

There might be licensing issues with this.  You're probably ok if you don't
redistribute the incomplete JDK.  (which may or may not be useful).

WILL

-----Original Message-----
From: Joaquim Carvalho [mailto:jrc@bookmarc.pt]
Sent: Tuesday, June 04, 2002 8:49 AM
To: Velocity Users List
Subject: Re: Can I get a Velocity version for Java 1.18



On Tuesday, June 4, 2002, at 01:10 PM, Geir Magnusson Jr. wrote:

>> For some reason I though 0.75 was good for java 1.18 but obviously I am
>> wrong.
>>
>> Any solution other than goind through the Velocity code and replace the
>> collections classes with references to the ones Sun supplies in
>> collections.zip?
>>
>
> Yuck.  That would be painful and you would then be stuck with that
> version.
>
> Is it possible to have a set of wrapper classes for backwards
> compatibility?
> I naively think this should be possible, at least for the basic stuff
> like
> collections?
>

You mean that I would, for instance, provide my own java.util.HashMap,
and other java 1.2 classes that Velocity needs?
I suppose I can do that.

Joaquim


--
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: Can I get a Velocity version for Java 1.18

Posted by Joaquim Carvalho <jr...@bookmarc.pt>.
On Tuesday, June 4, 2002, at 01:10 PM, Geir Magnusson Jr. wrote:

>> For some reason I though 0.75 was good for java 1.18 but obviously I am
>> wrong.
>>
>> Any solution other than goind through the Velocity code and replace the
>> collections classes with references to the ones Sun supplies in
>> collections.zip?
>>
>
> Yuck.  That would be painful and you would then be stuck with that 
> version.
>
> Is it possible to have a set of wrapper classes for backwards 
> compatibility?
> I naively think this should be possible, at least for the basic stuff 
> like
> collections?
>

You mean that I would, for instance, provide my own java.util.HashMap, 
and other java 1.2 classes that Velocity needs?
I suppose I can do that.

Joaquim


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


Re: Can I get a Velocity version for Java 1.18

Posted by "Geir Magnusson Jr." <ge...@adeptra.com>.
On 6/4/02 8:04 AM, "Joaquim Carvalho" <jr...@bookmarc.pt> wrote:

> Hello,
> 
> I need a version of Velocity for java 1.18.

Wow.

> 
> I had saved a Velocity 0.75 for this but I am getting a class not found
> related to HashMap
> 
> java.lang.NoClassDefFoundError: java/util/HashMap
>         at 
> org.apache.velocity.context.InternalContextBase.<init>
> (InternalContextBase.java:83)
> 
> 
> For some reason I though 0.75 was good for java 1.18 but obvously I am
> wrong.
> 
> Any solution other than goind through the Velocity code and replace the
> collections classes with references to the ones Sun supplies in
> collections.zip?
> 

Yuck.  That would be painful and you would then be stuck with that version.

Is it possible to have a set of wrapper classes for backwards compatibility?
I naively think this should be possible, at least for the basic stuff like
collections?


-- 
Geir Magnusson Jr.
Research & Development, Adeptra Inc.
geirm@adeptra.com
+1-203-247-1713



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


Can I get a Velocity version for Java 1.18

Posted by Joaquim Carvalho <jr...@bookmarc.pt>.
Hello,

I need a version of Velocity for java 1.18.

I had saved a Velocity 0.75 for this but I am getting a class not found 
related to HashMap

java.lang.NoClassDefFoundError: java/util/HashMap
        at 
org.apache.velocity.context.InternalContextBase.<init>
(InternalContextBase.java:83)


For some reason I though 0.75 was good for java 1.18 but obvously I am 
wrong.

Any solution other than goind through the Velocity code and replace the 
collections classes with references to the ones Sun supplies in 
collections.zip?


Joaquim


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


Re: velocity-tools and pageContext

Posted by "Geir Magnusson Jr." <ge...@adeptra.com>.
On 6/4/02 6:18 AM, "Gabriel Sidler" <si...@teamup.ch> wrote:

> Mathias Bogaert wrote:
> 
>> Hi,
>> 
>> I'm currently evaluating how add Velocity support to SiteMesh (
>> www.opensymphony.com/sitemesh ), but I
>> need a way to obtain the pageContext from the ViewContext. How can I do
>> this?
>> 
>> Thanks,
>> 
>> Mathias Bogaert
>> 
>> PS reply to pathos@pandora.be please
> 
> 
> Mathias,
> as far as I understand things, page context is a concept that is
> introduced by JSP. If you use a different view technology than
> JSP there is no page context. You would have to implemement it
> yourself.
> I am actually wondering if and how people have solved this in
> Velocity. In all my past Velocity/WebMacro apps I never had a
> need for a page context.

You need the pageContext in JSP because that's the internal API used for
tags, right?  So if you want the writer to do output, you need the page
context.

There is a context in velocity, and internally, in the directives and such,
we have our own pageContext-ish kind of thing, but that's really for
internal use.

Why would you need the pageContext?  You want to use Velocity within a JSP?

If so, take a look at the 'veltag' JSP tag.

 http://jakarta.apache.org/velocity/veltag.html

If that isn't what you need, it might be a good example to see how one might
go about integrating...


-- 
Geir Magnusson Jr.
Research & Development, Adeptra Inc.
geirm@adeptra.com
+1-203-247-1713



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


Re: velocity-tools and pageContext

Posted by Gabriel Sidler <si...@teamup.ch>.
Mathias Bogaert wrote:

> Hi,
> 
> I'm currently evaluating how add Velocity support to SiteMesh (
> www.opensymphony.com/sitemesh ), but I 
> need a way to obtain the pageContext from the ViewContext. How can I do
> this?
> 
> Thanks,
> 
> Mathias Bogaert
> 
> PS reply to pathos@pandora.be please


Mathias,
as far as I understand things, page context is a concept that is
introduced by JSP. If you use a different view technology than
JSP there is no page context. You would have to implemement it
yourself.
I am actually wondering if and how people have solved this in
Velocity. In all my past Velocity/WebMacro apps I never had a
need for a page context.

Gabe



--
Gabriel Sidler
Software Engineer, Eivycom GmbH, Zurich, Switzerland


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