You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Will Glass-Husain <wg...@forio.com> on 2004/01/26 16:08:11 UTC

Re: InputEventHandler

Hi Niall,

As the patch currently stands, it include some modifications to both the
EventCartridge package and the Parser package (changing the #include and
#parse directives).

Specifically, this feature allows you to customize the behavior of files
pulled in when the user enters a #include and a #parse directive.  You can
block the include or include a different file other than the one specified.
Possible uses include relative template includes and access control (e.g.
multiple users in multiple directories).  It doesn't affect the files pulled
in from getTemplate.  You'd have to write a custom resource loader to do
this.  (I think other multi-designer developers on the list have said this
is what they've done).

Geir's suggested the InputEventHandler patch go into 1.6.

WILL

----- Original Message ----- 
From: "Niall Gallagher" <ni...@analog.com>
To: "Velocity Users List" <ve...@jakarta.apache.org>
Sent: Monday, January 26, 2004 5:31 AM
Subject: Re: Active Learning Environment (Velocity/Java/XML)


> Hi
>
> Will Glass-Husain wrote:
>
> >Hi Brad,
> >
> >We have an app ( broadcast.forio.com ) that similarly has a number of
> >accounts for which different users upload Velocity pages.  (like your
app,
> >accounts are distinguished by pathinfo from the url).  We stuck with a
> >single VelocityEngine for performance reasons, with a few customizations.
A
> >few issues that may be parallel
> >
> >First, I was concerned about #include and #parse, so we implemented a
> >customized event handler (patch in Bugzilla) to restrict users to only be
> >able to include files within their own account.  (it's a little more
> >complex, as we also have a system-wide set of includeable files).
> >
> >
> Just a comment in relation to this patch, i.e the InputEventHandler. I
> was wondering you must have modified the VelocityEngine or
> RuntimeInstance at least to get this working. Also, if this appears in
> release 1.5 as is stated in bugzilla, will the
> VelocityEngine.getTemplate method provide similar mapping. For instance
> if there were a number of  designers and programmers each writing there
> respective templates and controllers, would the designer be able to
> configure the template mapping using a specialized EventCartrige ?
>
> Hope the InputEventHandler is added in 1.5 ;)
>
> Niall
>
> >
> >[1]
>
>http://nagoya.apache.org/wiki/apachewiki.cgi?BuildingSecureWebApplications
> >
> >
> >
> >----- Original Message ----- 
> >From: "Brad Cox" <bc...@virtualschool.edu>
> >To: "Tim Colson" <tc...@cisco.com>; "'Velocity Users List'"
> ><ve...@jakarta.apache.org>
> >Sent: Friday, January 23, 2004 10:06 AM
> >Subject: RE: Active Learning Environment (Velocity/Java/XML)
> >
> >
> >
> >>Thanks for the support, and the interest. Guess I better brush up on
> >>my mind-reading skills. ;)
> >>
> >>And please do send in those (constructive) comments and suggestions.
> >>The main problem is not sure how to provide for a foolproof,
> >>seamless, no configuration  install. Considering switching to
> >>berkeley db instead of mysql for this reason alone. TBD. Suggestions
> >>most welcome.
> >>
> >>PS: The main snag is that each course should have its own velocity
> >>engine for course-specific macros and a connection to its very own
> >>database. The ale servlet should handle multiple courses,
> >>distinguished via pathinfo from the url. Possible, I know, but messy
> >>to think through. When/how to trigger automatic database
> >>initialization is also an issue. I'm working on it. ;)
> >>
> >>At 10:41 AM -0700 1/23/04, Tim Colson wrote:
> >>
> >>>Brad -
> >>>
> >>>Will wrote:
> >>>
> >>>> Thanks for posting this, found it interesting.  Always
> >>>> interested to hear about other Velocity apps (especially related to
> >>>>
> >>>e-learning).
> >>>
> >>>> I'll download it and take a look, maybe send back some thoughts in a
> >>>> personal email.
> >>>>
> >>>Ditto. :-)
> >>>Timo
> >>>
> >>-- 
> >>Brad J. Cox, PhD, 703 361 4751, http://virtualschool.edu
> >>        http://virtualschool/ale Action Learning Environment
> >>http://virtualschool.edu/mybank Digital Rights Management System
> >>    http://virtualschool.edu/jco Java Cryptographic Objects (JCO)
> >>   http://virtualschool.edu/jwaa Java Web Application Architecture
(JWAA)
> >>  http://virtualschool.edu/java+ Java Preprocessor (Java+)
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> >>For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> >>
> >>
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> >
> >
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>


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


Re: InputEventHandler

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

Sounds like in your case a custom resource loader would be the best bet.
You can specify this independently of the servlet with a property in
velocity.properties, and it applies to getTemplate as well as #include /
#parse.

Although there has been discussion of configuring a event handler in
velocity.properties as well.

WILL

----- Original Message ----- 
From: "Niall Gallagher" <ni...@analog.com>
To: "Velocity Users List" <ve...@jakarta.apache.org>
Sent: Monday, January 26, 2004 8:07 AM
Subject: Re: InputEventHandler


> Hi,
>
> I think that this is a great idea and enables Velocity to scale very
> well, also it hides a lot of details from the template designer and
> should enable the path structure to change without affecting pages (i
> think). However, you mention that this does not influence the
> getTemplate method, does this confuse matters ? For example, you
> mentioned the path info providing a sort of mapping, so if this happened
>
> getTemplate("/niall/layout.vm");
>
> would the page look for
>
> #include("/file.vm")
>
> which really does
>
> #include("/niall/file.vm")
>
>
> Also, would it be possible/advisable to force/hide this behaviour from
> controllers such that the implementor of the Servlet/Object does not
> need to know about the mapping done ? As I am sure that in writing
> Servlets it would not be desirable to have to set EventCartriges each
> time, or to couple an individual Servlet with a specific mapping scheme.
>
> Somthing like ?
>
> public void merge(Context context, Writer out) throws Exception {
>     innerTemplate.merge(new MyMappingContext(context), out);
> }
>
>
> Niall
>
>
>
> Will Glass-Husain wrote:
>
> >Hi Niall,
> >
> >As the patch currently stands, it include some modifications to both the
> >EventCartridge package and the Parser package (changing the #include and
> >#parse directives).
> >
> >Specifically, this feature allows you to customize the behavior of files
> >pulled in when the user enters a #include and a #parse directive.  You
can
> >block the include or include a different file other than the one
specified.
> >Possible uses include relative template includes and access control (e.g.
> >multiple users in multiple directories).  It doesn't affect the files
pulled
> >in from getTemplate.  You'd have to write a custom resource loader to do
> >this.  (I think other multi-designer developers on the list have said
this
> >is what they've done).
> >
> >Geir's suggested the InputEventHandler patch go into 1.6.
> >
> >WILL
> >
> >----- Original Message ----- 
> >From: "Niall Gallagher" <ni...@analog.com>
> >To: "Velocity Users List" <ve...@jakarta.apache.org>
> >Sent: Monday, January 26, 2004 5:31 AM
> >Subject: Re: Active Learning Environment (Velocity/Java/XML)
> >
> >
> >
> >
> >>Hi
> >>
> >>Will Glass-Husain wrote:
> >>
> >>
> >>
> >>>Hi Brad,
> >>>
> >>>We have an app ( broadcast.forio.com ) that similarly has a number of
> >>>accounts for which different users upload Velocity pages.  (like your
> >>>
> >>>
> >app,
> >
> >
> >>>accounts are distinguished by pathinfo from the url).  We stuck with a
> >>>single VelocityEngine for performance reasons, with a few
customizations.
> >>>
> >>>
> >A
> >
> >
> >>>few issues that may be parallel
> >>>
> >>>First, I was concerned about #include and #parse, so we implemented a
> >>>customized event handler (patch in Bugzilla) to restrict users to only
be
> >>>able to include files within their own account.  (it's a little more
> >>>complex, as we also have a system-wide set of includeable files).
> >>>
> >>>
> >>>
> >>>
> >>Just a comment in relation to this patch, i.e the InputEventHandler. I
> >>was wondering you must have modified the VelocityEngine or
> >>RuntimeInstance at least to get this working. Also, if this appears in
> >>release 1.5 as is stated in bugzilla, will the
> >>VelocityEngine.getTemplate method provide similar mapping. For instance
> >>if there were a number of  designers and programmers each writing there
> >>respective templates and controllers, would the designer be able to
> >>configure the template mapping using a specialized EventCartrige ?
> >>
> >>Hope the InputEventHandler is added in 1.5 ;)
> >>
> >>Niall
> >>
> >>
> >>
> >>>[1]
> >>>
> >>>
>
>>http://nagoya.apache.org/wiki/apachewiki.cgi?BuildingSecureWebApplications
> >>
> >>
> >>>
> >>>----- Original Message ----- 
> >>>From: "Brad Cox" <bc...@virtualschool.edu>
> >>>To: "Tim Colson" <tc...@cisco.com>; "'Velocity Users List'"
> >>><ve...@jakarta.apache.org>
> >>>Sent: Friday, January 23, 2004 10:06 AM
> >>>Subject: RE: Active Learning Environment (Velocity/Java/XML)
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>>Thanks for the support, and the interest. Guess I better brush up on
> >>>>my mind-reading skills. ;)
> >>>>
> >>>>And please do send in those (constructive) comments and suggestions.
> >>>>The main problem is not sure how to provide for a foolproof,
> >>>>seamless, no configuration  install. Considering switching to
> >>>>berkeley db instead of mysql for this reason alone. TBD. Suggestions
> >>>>most welcome.
> >>>>
> >>>>PS: The main snag is that each course should have its own velocity
> >>>>engine for course-specific macros and a connection to its very own
> >>>>database. The ale servlet should handle multiple courses,
> >>>>distinguished via pathinfo from the url. Possible, I know, but messy
> >>>>to think through. When/how to trigger automatic database
> >>>>initialization is also an issue. I'm working on it. ;)
> >>>>
> >>>>At 10:41 AM -0700 1/23/04, Tim Colson wrote:
> >>>>
> >>>>
> >>>>
> >>>>>Brad -
> >>>>>
> >>>>>Will wrote:
> >>>>>
> >>>>>
> >>>>>
> >>>>>>Thanks for posting this, found it interesting.  Always
> >>>>>>interested to hear about other Velocity apps (especially related to
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>e-learning).
> >>>>>
> >>>>>
> >>>>>
> >>>>>>I'll download it and take a look, maybe send back some thoughts in a
> >>>>>>personal email.
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>Ditto. :-)
> >>>>>Timo
> >>>>>
> >>>>>
> >>>>>
> >>>>-- 
> >>>>Brad J. Cox, PhD, 703 361 4751, http://virtualschool.edu
> >>>>       http://virtualschool/ale Action Learning Environment
> >>>>http://virtualschool.edu/mybank Digital Rights Management System
> >>>>   http://virtualschool.edu/jco Java Cryptographic Objects (JCO)
> >>>>  http://virtualschool.edu/jwaa Java Web Application Architecture
> >>>>
> >>>>
> >(JWAA)
> >
> >
> >>>> http://virtualschool.edu/java+ Java Preprocessor (Java+)
> >>>>
> >>>>---------------------------------------------------------------------
> >>>>To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> >>>>For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> >>>>
> >>>>
> >>>>
> >>>>
> >>>---------------------------------------------------------------------
> >>>To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> >>>For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> >>For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> >>
> >>
> >>
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> >
> >
> >
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>


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


Re: InputEventHandler

Posted by Niall Gallagher <ni...@analog.com>.
Hi,

I think that this is a great idea and enables Velocity to scale very 
well, also it hides a lot of details from the template designer and 
should enable the path structure to change without affecting pages (i 
think). However, you mention that this does not influence the 
getTemplate method, does this confuse matters ? For example, you 
mentioned the path info providing a sort of mapping, so if this happened

getTemplate("/niall/layout.vm");

would the page look for

#include("/file.vm")

which really does

#include("/niall/file.vm")


Also, would it be possible/advisable to force/hide this behaviour from 
controllers such that the implementor of the Servlet/Object does not 
need to know about the mapping done ? As I am sure that in writing 
Servlets it would not be desirable to have to set EventCartriges each 
time, or to couple an individual Servlet with a specific mapping scheme.

Somthing like ?

public void merge(Context context, Writer out) throws Exception {
    innerTemplate.merge(new MyMappingContext(context), out);
}


Niall



Will Glass-Husain wrote:

>Hi Niall,
>
>As the patch currently stands, it include some modifications to both the
>EventCartridge package and the Parser package (changing the #include and
>#parse directives).
>
>Specifically, this feature allows you to customize the behavior of files
>pulled in when the user enters a #include and a #parse directive.  You can
>block the include or include a different file other than the one specified.
>Possible uses include relative template includes and access control (e.g.
>multiple users in multiple directories).  It doesn't affect the files pulled
>in from getTemplate.  You'd have to write a custom resource loader to do
>this.  (I think other multi-designer developers on the list have said this
>is what they've done).
>
>Geir's suggested the InputEventHandler patch go into 1.6.
>
>WILL
>
>----- Original Message ----- 
>From: "Niall Gallagher" <ni...@analog.com>
>To: "Velocity Users List" <ve...@jakarta.apache.org>
>Sent: Monday, January 26, 2004 5:31 AM
>Subject: Re: Active Learning Environment (Velocity/Java/XML)
>
>
>  
>
>>Hi
>>
>>Will Glass-Husain wrote:
>>
>>    
>>
>>>Hi Brad,
>>>
>>>We have an app ( broadcast.forio.com ) that similarly has a number of
>>>accounts for which different users upload Velocity pages.  (like your
>>>      
>>>
>app,
>  
>
>>>accounts are distinguished by pathinfo from the url).  We stuck with a
>>>single VelocityEngine for performance reasons, with a few customizations.
>>>      
>>>
>A
>  
>
>>>few issues that may be parallel
>>>
>>>First, I was concerned about #include and #parse, so we implemented a
>>>customized event handler (patch in Bugzilla) to restrict users to only be
>>>able to include files within their own account.  (it's a little more
>>>complex, as we also have a system-wide set of includeable files).
>>>
>>>
>>>      
>>>
>>Just a comment in relation to this patch, i.e the InputEventHandler. I
>>was wondering you must have modified the VelocityEngine or
>>RuntimeInstance at least to get this working. Also, if this appears in
>>release 1.5 as is stated in bugzilla, will the
>>VelocityEngine.getTemplate method provide similar mapping. For instance
>>if there were a number of  designers and programmers each writing there
>>respective templates and controllers, would the designer be able to
>>configure the template mapping using a specialized EventCartrige ?
>>
>>Hope the InputEventHandler is added in 1.5 ;)
>>
>>Niall
>>
>>    
>>
>>>[1]
>>>      
>>>
>>http://nagoya.apache.org/wiki/apachewiki.cgi?BuildingSecureWebApplications
>>    
>>
>>>
>>>----- Original Message ----- 
>>>From: "Brad Cox" <bc...@virtualschool.edu>
>>>To: "Tim Colson" <tc...@cisco.com>; "'Velocity Users List'"
>>><ve...@jakarta.apache.org>
>>>Sent: Friday, January 23, 2004 10:06 AM
>>>Subject: RE: Active Learning Environment (Velocity/Java/XML)
>>>
>>>
>>>
>>>      
>>>
>>>>Thanks for the support, and the interest. Guess I better brush up on
>>>>my mind-reading skills. ;)
>>>>
>>>>And please do send in those (constructive) comments and suggestions.
>>>>The main problem is not sure how to provide for a foolproof,
>>>>seamless, no configuration  install. Considering switching to
>>>>berkeley db instead of mysql for this reason alone. TBD. Suggestions
>>>>most welcome.
>>>>
>>>>PS: The main snag is that each course should have its own velocity
>>>>engine for course-specific macros and a connection to its very own
>>>>database. The ale servlet should handle multiple courses,
>>>>distinguished via pathinfo from the url. Possible, I know, but messy
>>>>to think through. When/how to trigger automatic database
>>>>initialization is also an issue. I'm working on it. ;)
>>>>
>>>>At 10:41 AM -0700 1/23/04, Tim Colson wrote:
>>>>
>>>>        
>>>>
>>>>>Brad -
>>>>>
>>>>>Will wrote:
>>>>>
>>>>>          
>>>>>
>>>>>>Thanks for posting this, found it interesting.  Always
>>>>>>interested to hear about other Velocity apps (especially related to
>>>>>>
>>>>>>            
>>>>>>
>>>>>e-learning).
>>>>>
>>>>>          
>>>>>
>>>>>>I'll download it and take a look, maybe send back some thoughts in a
>>>>>>personal email.
>>>>>>
>>>>>>            
>>>>>>
>>>>>Ditto. :-)
>>>>>Timo
>>>>>
>>>>>          
>>>>>
>>>>-- 
>>>>Brad J. Cox, PhD, 703 361 4751, http://virtualschool.edu
>>>>       http://virtualschool/ale Action Learning Environment
>>>>http://virtualschool.edu/mybank Digital Rights Management System
>>>>   http://virtualschool.edu/jco Java Cryptographic Objects (JCO)
>>>>  http://virtualschool.edu/jwaa Java Web Application Architecture
>>>>        
>>>>
>(JWAA)
>  
>
>>>> http://virtualschool.edu/java+ Java Preprocessor (Java+)
>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>>>>For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>>>>
>>>>
>>>>        
>>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>>>
>>>
>>>
>>>
>>>      
>>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>>
>>    
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
>
>  
>



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