Velocity Question

View: New views
5 Messages — Rating Filter:   Alert me  

Velocity Question

by Gautam Joshi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
 
I am planning to use Velocity for a metadata driven UI framework.
A velocity template at will be fed the UI metadata from the database.
Based on this metadata,
this template will then invoke other velocity templates. I plan to have
templates defined for Text fields, Select Boxes, etc.
Based on the type and number of fields defined in the metadata, the
topmost velocity template in turn will call these other templates that
handle specific field types.
I do not expect the metadata to have more than 50 fields.
Do you think this approach will cause any memory or performance issues?
 
I would really appreciate if someone could share their thoughts and
prior experiences.
 
Thanks
-Gautam

Re: Velocity Question

by Tim Kelly :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have used this approach in my application and found velocity macros to be
handy for field level html elements.  Then use specific velocity files to
define pages.  I don't think you'll run into any memory or CPU issues with
the approach we run our production servers with 4GB of memory and dual 2GHz
64 bit processors.  The CPU usage has never gotten above 10% with 40,000
page views/day.  I sized the JVM to run with 2GB and haven't hit any out of
memory errors.

Tim

On Tue, Mar 18, 2008 at 2:59 PM, Gautam Joshi (jgautam) <jgautam@...>
wrote:

> Hi,
>
> I am planning to use Velocity for a metadata driven UI framework.
> A velocity template at will be fed the UI metadata from the database.
> Based on this metadata,
> this template will then invoke other velocity templates. I plan to have
> templates defined for Text fields, Select Boxes, etc.
> Based on the type and number of fields defined in the metadata, the
> topmost velocity template in turn will call these other templates that
> handle specific field types.
> I do not expect the metadata to have more than 50 fields.
> Do you think this approach will cause any memory or performance issues?
>
> I would really appreciate if someone could share their thoughts and
> prior experiences.
>
> Thanks
> -Gautam
>



--
Tim Kelly
Director of Development
275 Wyman Street
Waltham, MA 02451

Phone: 781.290.5300
Mobile: 508.561.0985
Fax:781.290.5305
http://www.buildingengines.com/

Re: Velocity Question

by Adrian Tarau :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Gautam,

I had the same problem, rendering an UI model as HTML(plain HTML or
JavaScript/HTML).
My solution is to have a directive called #function(name param1 param2
...) and the function is actually an abstractization,* *you can have a
function implemented in Java or can be another template(even a different
engine). The function implementation can specify if the context changes
propagates or are local to the function(by default are local and this
should be the way to go) . I can mix different template engines, for
example I can call a FreeMarker template from my Velocity template ;)

I didn't had time to do some performance testing, but I don't think
there will be performance penalties and the memory consumption will be
the same as loading all 50 templates in memory.

I can send you the link to the source code if you want to have a look.

Gautam Joshi (jgautam) wrote:

> Hi,
>  
> I am planning to use Velocity for a metadata driven UI framework.
> A velocity template at will be fed the UI metadata from the database.
> Based on this metadata,
> this template will then invoke other velocity templates. I plan to have
> templates defined for Text fields, Select Boxes, etc.
> Based on the type and number of fields defined in the metadata, the
> topmost velocity template in turn will call these other templates that
> handle specific field types.
> I do not expect the metadata to have more than 50 fields.
> Do you think this approach will cause any memory or performance issues?
>  
> I would really appreciate if someone could share their thoughts and
> prior experiences.
>  
> Thanks
> -Gautam
>
>  


Re: Velocity Question

by Gautam Joshi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Adrian,

Thanks for your response.

Could you send me extracts from your code to illustrate how you define a function and make calls to other Velocity templates and external engines from a velocity template.

Thanks
Gautam

Adrian Tarau wrote:
Hello Gautam,

I had the same problem, rendering an UI model as HTML(plain HTML or
JavaScript/HTML).
My solution is to have a directive called #function(name param1 param2
...) and the function is actually an abstractization,* *you can have a
function implemented in Java or can be another template(even a different
engine). The function implementation can specify if the context changes
propagates or are local to the function(by default are local and this
should be the way to go) . I can mix different template engines, for
example I can call a FreeMarker template from my Velocity template ;)

I didn't had time to do some performance testing, but I don't think
there will be performance penalties and the memory consumption will be
the same as loading all 50 templates in memory.

I can send you the link to the source code if you want to have a look.

Gautam Joshi (jgautam) wrote:
> Hi,
>  
> I am planning to use Velocity for a metadata driven UI framework.
> A velocity template at will be fed the UI metadata from the database.
> Based on this metadata,
> this template will then invoke other velocity templates. I plan to have
> templates defined for Text fields, Select Boxes, etc.
> Based on the type and number of fields defined in the metadata, the
> topmost velocity template in turn will call these other templates that
> handle specific field types.
> I do not expect the metadata to have more than 50 fields.
> Do you think this approach will cause any memory or performance issues?
>  
> I would really appreciate if someone could share their thoughts and
> prior experiences.
>  
> Thanks
> -Gautam
>
>  

Re: Velocity Question

by Gautam Joshi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Tim,
Thanks for your respones.
That makes me feel much more confident.

Thanks
Gautam
Tim Kelly wrote:
I have used this approach in my application and found velocity macros to be
handy for field level html elements.  Then use specific velocity files to
define pages.  I don't think you'll run into any memory or CPU issues with
the approach we run our production servers with 4GB of memory and dual 2GHz
64 bit processors.  The CPU usage has never gotten above 10% with 40,000
page views/day.  I sized the JVM to run with 2GB and haven't hit any out of
memory errors.

Tim

On Tue, Mar 18, 2008 at 2:59 PM, Gautam Joshi (jgautam) <jgautam@cisco.com>
wrote:

> Hi,
>
> I am planning to use Velocity for a metadata driven UI framework.
> A velocity template at will be fed the UI metadata from the database.
> Based on this metadata,
> this template will then invoke other velocity templates. I plan to have
> templates defined for Text fields, Select Boxes, etc.
> Based on the type and number of fields defined in the metadata, the
> topmost velocity template in turn will call these other templates that
> handle specific field types.
> I do not expect the metadata to have more than 50 fields.
> Do you think this approach will cause any memory or performance issues?
>
> I would really appreciate if someone could share their thoughts and
> prior experiences.
>
> Thanks
> -Gautam
>



--
Tim Kelly
Director of Development
275 Wyman Street
Waltham, MA 02451

Phone: 781.290.5300
Mobile: 508.561.0985
Fax:781.290.5305
http://www.buildingengines.com/