Velosurf 2.0
Velosurf 2.0 has just been released. Velosurf is a database mapping layer for the Apache Velocity template engine. It provides automatic database mapping of tables and relationships without any code generation. In the context of a Webapp, it also provides handy tools for authentication, localization, and forms validation. Homepage: http://velosurf.sourrceforge.net Claude - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Velosurf 2.0
Le vendredi 10 novembre 2006 à 06:00 -0800, Will Glass-Husain a écrit : Congratulations, Claude-- looks really nice! You're talking about the new logo? Yes, I'm very proud of it! ;-) (obviously you meant the link below: http://velosurf.sourceforge.net Thanks for the correction! Claude ) WILL On 11/10/06, Claude Brisson [EMAIL PROTECTED] wrote: Velosurf 2.0 has just been released. Velosurf is a database mapping layer for the Apache Velocity template engine. It provides automatic database mapping of tables and relationships without any code generation. In the context of a Webapp, it also provides handy tools for authentication, localization, and forms validation. Homepage: http://velosurf.sourrceforge.net Claude - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: FileResourceLoader and resource loaders generally: getting the context of a request
Velocity 1.5 supports relative resource loading with #include and #parse. The 1.5 release is not ready yet but should be quite stable. You can grab it from subversion. To enable relative resource loading, put the following line in your velocity.properties file: eventhandler.include.class = org.apache.velocity.app.event.implement.IncludeRelativePath Claude Le jeudi 09 novembre 2006 à 09:38 +, Townson, Chris a écrit : Hi all, I'm just trying to work out if this is possible and how it would be done: The problem: Currently, we're using FileResourceLoader to retrieve templates from the filesystem in the normal. I'm in the process of putting together a slightly customized version of this to resolve ambiguous requests (e.g. if templateName == null or length == 0, use look for a welcome file as configured in web.xml) ... we need to do this because the way we're running velocity is through a servlet which takes the template path as a request attribute, parameter or path info. However, this means that it becomes impossible to #include or #parse a file without referencing it using the full path (i.e. #parse(anotherFileInThisFolder.vm) fails) What I would like to do is, if we get a request like this, to add a test which discovers the path from _where_ the call was made and then normalizes it based on that information. Possible? Thanks in advance, Chris p.s. congratulations on going TLP! :D --- christopher townson - new technology developer nature publishing group - 4 crinan st., london t. +44 (20) 7843-4644 e. [EMAIL PROTECTED] DISCLAIMER: This e-mail is confidential and should not be used by anyone who is not the original intended recipient. If you have received this e-mail in error please inform the sender and delete it from your mailbox or any other storage mechanism. Neither Macmillan Publishers Limited nor any of its agents accept liability for any statements made which are clearly the sender's own and not expressly made on behalf of Macmillan Publishers Limited or one of its agents. Please note that neither Macmillan Publishers Limited nor any of its agents accept any responsibility for viruses that may be contained in this e-mail or its attachments and it is your responsibility to scan the e-mail and attachments (if any). No contracts may be concluded on behalf of Macmillan Publishers Limited or its agents by means of e-mail communication. Macmillan Publishers Limited Registered in England and Wales with registered number 785998 Registered Office Brunel Road, Houndmills, Basingstoke RG21 6XS - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Simple question regarding including double quotes in #set
Try this: #set($q = '') #set($keywords = 'meta name=${q}keywords${q} content=${q}information, xyz, something, $person.name, $person.address${q}/') Claude Le mercredi 18 octobre 2006 à 13:37 +0530, Manish a écrit : How do I include double quotes in the #set variables? This is what I am trying to get working, note that including this in single quotes won't render some variable values that I want. #set($keywords = 'meta name=keywords content=information, xyz, something, $person.name, $person.address/') TIA, - Manish - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: getting list of all context values
By default, the context is not included in itself, but you can still list the values in the session, request or response (or also in the servlet context, known as application) with the following loops: #foreach($key in $request.attributeNames) ... #foreach($key in $session.attributeNames) ... #foreach($key in $application.attributeNames) ... If you need the context to have a key towards itself, you have to subclass the VelocityViewServlet, and inherit createContext like this: protected Context createContext(HttpServletRequest request, HttpServletResponse response) { Context context = super.CreateContext(request,response); context.put(context,context); } You can then iterate on values of the context like this: ul #foreach($key in $context.keys) li$key = $context.get('$key') #end /ul but the values in the request, session, response and application won't appear in this list. Claude Le mardi 17 octobre 2006 à 18:18 -0400, Charles Harvey III a écrit : Hello. If I am using the VelocityLayoutServlet where all things that I put into the request, response and session automatically go into the $context. So... how do I get a list of all the values in the $context? Just for starters, how do I access the $context? It is not with $context. I can access $request, $response and $session. So, how do I get at the $context? Thanks much. Charlie - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Returning a null object from hanleRequest
Yes, you can ignore the warning. No, there is no other way to indicate to Velocity that there is no template to render. What you can do to get rid of the warning is move the code that handles responses itself to another servlet which doesn't inherit VelocityViewServlet, and adjust the mappings correspondingly in web.xml, if feasible. Claude Le mercredi 11 octobre 2006 à 15:22 +0100, Steve O'Hara a écrit : I have a Tomcat application where I am extending VelocityViewServlet and overriding handleRequest with my handler. There are circumstances where I am handling streaming back to the browser myself and I don't want Velocity to render a template. In these situations, I return a null from handleRequest which works OK. However, now that I have turned on logging for Velocity I notice that there are warnings each time I do this like VelocityViewServlet: couldn't find template to match request Is it safe to ignore these are should I be doing something else to indicate to Velocity that there is no template to render? Thanks, Steve - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: help in calling a class in a velocity template
Do you mean : How to put a new instance of a class in the velocity context from inside the vtl? Usually, you put classes in the context using java (context.put(name,object)), or using toolbox.xml if you rely on the VelocityTools subproject. Now, if you really want to load a new instance of a class in the context from inside the VTL, you have the following hack: #set($newobject = $foo.class.forName(myclass).newInstance()) where $foo can be any existing reference. But this is really not a very clean coding style... Also, the class you load must have a default constructor (otherwise it is still possible but more complex). By the way, dev people, why is this issue only scheduled for 1.6? Will's patch seems to be ready in http://issues.apache.org/jira/browse/VELOCITY-179 and backward compatible with proper default configuration value. Claude Le vendredi 29 septembre 2006 à 10:27 -0400, sandesh makam a écrit : hi, Can any body tell me how i can call a class in a velocity template. I am trying to write a template which call a class that allows me to build a tree. thankyou - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Hashtable question
So it looks like you finally managed to achieve your setup. Good to know! Well, we prefer to talk about Maps than about Hashtables. A Map is in fact pretty similar with the concept of array in javascript or php (whereas in java arrays can only have natural integer incides): it's a set of correspondences between unique keys and values. In Velocity, we call them Maps, and you will need to install the lattest (1.5-beta) version to be able to create them from inside the templates. Since it has just been released, it's not easy to find but for now you can download it from here : http://cvs.apache.org/dist/jakarta/velocity/v1.5beta1/velocity-1.5-beta1.zip Then, you can issue a ant docs in the build directory to build the html docs locally (or wait a couple of days, I'm pretty sure they'll be available soon online). You'll find in them anything you ever wanted to know about maps in velocity. Claude Le vendredi 22 septembre 2006 à 15:54 -0700, Brenton Strine a écrit : I'm familiar with javascript, but not Java or any other programming languages. I want to learn how to use hashtables in Velocity. Where can I find information telling me what a hashtable is exactly and what can be done with it? Thanks Brenton - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Beginner trying to install velocity to apache server
Peter, recommending Struts and Hibernate to a newcomer isn't very pedagogic neither pertinent. I'm telling people to avoid them... Telling him that he needs to know java isn't either. Do you need to know c++ to use apache/php ? Brenton, as said before, Velocity itself is just a template engine that will take a template file plus a context (a set of keys that map to data or objects) and output the formatted file. To connect it to the web, you will need two things: a java servlet container (tomcat or resin or jboss or jetty or...), and a webapp (a simple servlet or a set of servlets that compose a framework like Struts or Click). Here is what I would do: 1) Install the java servlet container. If you easily manage to install Tomcat with Apache, then ok. Elsewhere, you can also try Resin (caucho.com), which is an all-in-one web server (like Apache) plus servlet container (like Tomcat). 2) Once installed, figure out in your servlet container where are the webapps stored to plug-in your own one. I suggest you start with the simple webapp example from the velocity-tools subproject (otherwise Click is pretty cool also but needs java coding). 3) Populate your context (for instance, add a date formatting tool under the $date key). The velocity-tools subproject allows you to do so by means of a single toolbox.xml file, located under the WEB-INF subdirectory of the webapp(*). Check for the generic tools and the view tools in the docs of the velocity-tools subproject. 4) Play around with the template files... (*) The WEB-INF directory of a webapp is the directory where the webapp stores all its administrative files. Under it there are some other directories of interest: - the /WEB-INF/lib directory is the place to put any needed java library to be used by the webapp. Be sure to restart the webapp when you add libraries or change the toolbox.xml. - the /WEB-INF/log directory, especially the /WEB-INF/log/error.log file, that you should check everytimes something doesn't work as expected. And don't hesitate to ask... Regards, Claude Le vendredi 22 septembre 2006 à 13:52 +1200, Peter Harrison a écrit : On Thu, 2006-09-21 at 18:05 -0700, Brenton Strine wrote: Hi, I've set up apache with PHP before, but only with extensive help from howto guides. Now I want to be able to test velocity (index.vm) pages on my home computer. I tried to set it all up, but it doesn't seem to be working. Here is what I've done so far on my Windows XP computer: snip Apache doesn't serve VM files. Velocity is a Java template engine that many Java web applications use to render pages. Unlike PHP and Perl there is no module you can plug into Apache to render Velocity. You can have Apache connect to Tomcat, but thats quite complex if you are just learning. One easy way to get started is to download Tomcat (jakarta.apache.org/tomcat) and run it. You will need to know Java and probably learn to use Struts if your application will be of any size. As for books on the subjects, there are quite a few. One released in 2002 called Mastering Tomcat Development might give you a broad understanding of Tomcat, and I recommend it because I wrote it :) Seriously though, there are many good books on Tomcat now, although you should look for something that also covers Struts and Hibernate - Struts being a system of wiring your applications together, and Hibernate which provides a object data persistence framework. Together with Velocity they provide a very mature technology stack that has been well tested. Finally; there is no reason to front Tomcat with Apache anymore. It is still an option, but I have run application servers for years serving a large company with no separate static content provider. When learning to write java web applications its easier to do away with the extra complexity of Apache. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Click and tools (was: Re: pls help on Velocity-servlets)
Hi. My question is in fact: do you plan to integrate the toolbox.xml mechanism into Click? The aibility to populate the context with standard tools via toolbox.xml is something that Click shouldn't miss. Or maybe is this integration trivial? Thanks, Claude Le vendredi 14 juillet 2006 à 09:21 +1000, Malcolm Edgar a écrit : Hi Claude, well actually Click does rely on velocity-tools as it uses org.apache.velocity.tools.view.servlet.WebappLoader for loading Velocity templates. Click also uses concepts from Velocity Tools with a Format object used form formatting objects in templates: http://click.sourceforge.net/docs/click-api/net/sf/click/util/Format.html The scope of the Click Framework is different than Velocity Tools. Velocity Tools provides a lowerer level library for integrating with other frameworks and general Velocity development. While Click provides a higher level web application framework which supports Page and component oriented design, event based programming model, etc. regads Malcolm Edgar On 7/14/06, Claude Brisson [EMAIL PROTECTED] wrote: Malcolm, do you plan to have Click rely on velocity-tools toolbox sooner or later ? Then Click would become really interesting! Claude Le mercredi 12 juillet 2006 à 15:35 +1000, Malcolm Edgar a écrit : plug Click Framework is also a good way of using Velocity for web appliations /plug regards Malcolm Edgar http://click.sourceforge.net On 7/12/06, Will Glass-Husain [EMAIL PROTECTED] wrote: Hi Tom, You probably want to download the sub project Velocity Tools. Use the VelocityViewServlet -- it's the best approach. Also, read this article. It includes a simple tutorial http://jakarta.apache.org/velocity/webapps.html WILL Tom Jerry wrote: hi... I have a simple servlet and velocity program.. for eg. Sample.java and email.vm ... and when the vm file is run in a browser, nothing is displayed.. which means the template is not loaded properly . email.vm is in pets folder (pets/email.vm) and Sample.class is in pets/WEB-INF/classes folder. I gave the simple code as : Template t = getTemplate (email.vm); I am new to Velocity... and while googling, I found that webAppLoader is the best way to load templates. How to use it ??? And which is the proper way.. having a velocity.properties file or setting the properties in the Servlet java file ??? Please guide me. Regards, Snowy -- Forio Business Simulations Will Glass-Husain phone (415) 440-7500 x89 mobile (415) 235-4293 [EMAIL PROTECTED] www.forio.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Click and tools (was: Re: pls help on Velocity-servlets)
Le vendredi 21 juillet 2006 à 09:53 +1000, Malcolm Edgar a écrit : Hi Claude, I haven't had anyone ask for this yet, or had any need personally. What features out of the Toolbox do you need? The ability to put POJOs into the context for application/session/request scope in toolbox.xml without writing any single line of java, as with the VelocityViewServlet. The Click pattern is for users to define a custom Format object which is automatically added to the VelocityContext, this class includes a lot of formatting options. Much of it inspired by VelocityTools. If you need more specific stuff out of the toolbox, you would override the ClickServlet method createVelocityContext() I'm not sure this is sufficient to handle scopes. I think the way to go is to have the ClickServlet use the XMLToolboxManager the same way the VelocityViewServlet does. I'm really too busy to contribute this kind of stuff right now, but since it is a quite generic feature, I thought you might be interested for Click... Regards, Claude http://click.sourceforge.net/docs/click-api/net/sf/click/ClickServlet.html#createVelocityContext(net.sf.click.Page) And add your custom objects: public CustomClickServlet extends ClickServlet { protected VelocityContext createVelocityContext( Page page) { VelocityContext context = super.createVelocityContext(page); context.put(math, new MathTool()); return context; } } regards Malcolm Edgar On 7/20/06, Claude Brisson [EMAIL PROTECTED] wrote: Hi. My question is in fact: do you plan to integrate the toolbox.xml mechanism into Click? The aibility to populate the context with standard tools via toolbox.xml is something that Click shouldn't miss. Or maybe is this integration trivial? Thanks, Claude Le vendredi 14 juillet 2006 à 09:21 +1000, Malcolm Edgar a écrit : Hi Claude, well actually Click does rely on velocity-tools as it uses org.apache.velocity.tools.view.servlet.WebappLoader for loading Velocity templates. Click also uses concepts from Velocity Tools with a Format object used form formatting objects in templates: http://click.sourceforge.net/docs/click-api/net/sf/click/util/Format.html The scope of the Click Framework is different than Velocity Tools. Velocity Tools provides a lowerer level library for integrating with other frameworks and general Velocity development. While Click provides a higher level web application framework which supports Page and component oriented design, event based programming model, etc. regads Malcolm Edgar On 7/14/06, Claude Brisson [EMAIL PROTECTED] wrote: Malcolm, do you plan to have Click rely on velocity-tools toolbox sooner or later ? Then Click would become really interesting! Claude Le mercredi 12 juillet 2006 à 15:35 +1000, Malcolm Edgar a écrit : plug Click Framework is also a good way of using Velocity for web appliations /plug regards Malcolm Edgar http://click.sourceforge.net On 7/12/06, Will Glass-Husain [EMAIL PROTECTED] wrote: Hi Tom, You probably want to download the sub project Velocity Tools. Use the VelocityViewServlet -- it's the best approach. Also, read this article. It includes a simple tutorial http://jakarta.apache.org/velocity/webapps.html WILL Tom Jerry wrote: hi... I have a simple servlet and velocity program.. for eg. Sample.java and email.vm ... and when the vm file is run in a browser, nothing is displayed.. which means the template is not loaded properly . email.vm is in pets folder (pets/email.vm) and Sample.class is in pets/WEB-INF/classes folder. I gave the simple code as : Template t = getTemplate ( email.vm); I am new to Velocity... and while googling, I found that webAppLoader is the best way to load templates. How to use it ??? And which is the proper way.. having a velocity.properties file or setting the properties in the Servlet
Re: pls help on Velocity-servlets
Malcolm, do you plan to have Click rely on velocity-tools toolbox sooner or later ? Then Click would become really interesting! Claude Le mercredi 12 juillet 2006 à 15:35 +1000, Malcolm Edgar a écrit : plug Click Framework is also a good way of using Velocity for web appliations /plug regards Malcolm Edgar http://click.sourceforge.net On 7/12/06, Will Glass-Husain [EMAIL PROTECTED] wrote: Hi Tom, You probably want to download the sub project Velocity Tools. Use the VelocityViewServlet -- it's the best approach. Also, read this article. It includes a simple tutorial http://jakarta.apache.org/velocity/webapps.html WILL Tom Jerry wrote: hi... I have a simple servlet and velocity program.. for eg. Sample.java and email.vm ... and when the vm file is run in a browser, nothing is displayed.. which means the template is not loaded properly . email.vm is in pets folder (pets/email.vm) and Sample.class is in pets/WEB-INF/classes folder. I gave the simple code as : Template t = getTemplate (email.vm); I am new to Velocity... and while googling, I found that webAppLoader is the best way to load templates. How to use it ??? And which is the proper way.. having a velocity.properties file or setting the properties in the Servlet java file ??? Please guide me. Regards, Snowy -- Forio Business Simulations Will Glass-Husain phone (415) 440-7500 x89 mobile (415) 235-4293 [EMAIL PROTECTED] www.forio.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Check Browsers
There is a BrowserSnifferTool in the toolbox: http://jakarta.apache.org/velocity/tools/javadoc/org/apache/velocity/tools/view/tools/BrowserSnifferTool.html Claude Le mercredi 24 mai 2006 à 18:29 +0100, Ruben Fragoso a écrit : Hi I would like to know if it is possibile, to check the browser using velocity. Thank you in advance. Ruben - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Nested, cartesian loop of dynamic values
Hi You should check the RenderTool (or the ViewRenderTool if you are using the VelocityViewServlet). http://jakarta.apache.org/velocity/tools/generic/RenderTool.html To use the RenderTool tool, you've got to put it in the context, as long as the context itself. You can then write things like ${function}('$parameter') = $render.eval($context,${function}.invoke($parameter)) (I'm kinda gessing the 'invoke' syntax since I donno your function objects...) Considering your problem from another perspective, you could also maybe use reflection... but you should give more details about your function objects for hints about this option. Claude Le jeudi 11 mai 2006 à 11:10 -0700, Sriram Gopalan a écrit : Hi, Here is my requirement. I have a list of function objects in java that I can put into my velocity context. All these functions (methods) take one parameter each. I also have this list of parameters that the functions take. I need to be able to print the invoked return value of these methods into my output file. As an example, assume my functions are: functions = {'getName', 'getAge','getSalary'...}; parameters = {'John','Joe','Jack','Mary'...} and I want the output to be of the following format: getName('John') = John Smith getName('Joe') = Joe Doe . . . getAge('Jack') = 36 . . . getSalary('Mary') = 3 . . . and so on. I hope my predicament is clear. The left hand side of the output lines are easy ($function.name, $parameter.name etc.) However, the right hand side is dynamic and actually depends on the runtime evaluated output value of invoking $function on $parameter. What are the various ways in which I can do this? What would my template look like? #foreach ($function in $functions) #foreach ($parameter in $parameters) $function.name('$parameter.name') = ## WHAT COMES HERE? #end #end Thanks for the help in advance. regards, Sriram Gopalan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Switching from PHP to Java/Velocity, Performance?
Le jeudi 13 avril 2006 à 11:43 +0200, Dominik Bruhn a écrit : My plans were to Use a VelocityViewServlet and Velocity-Templates. In between a small layer for abstraction and Page-Handling and Permissions. As Database-Layer I use JDBC. I tired Hibernate but I haven't seen any advandages in it. I agree. Le jeudi 13 avril 2006 à 14:40 +0300, Florin Vancea a écrit : Of course JDBC would work, but as soon as the complexity grows, you may want a layer that shields you from it. It's the same better/ugly issue. True, but Hibernate seems overkill for this task. You can have a look at Velosurf. It's a small database access layer that won't induce any bottleneck by it owns. Nowadays, every good database will already have a built-in caching mechanism. Claude - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Switching from PHP to Java/Velocity, Performance?
Le jeudi 13 avril 2006 à 16:37 +0300, Florin Vancea a écrit : You can have a look at Velosurf. It's a small database access layer that won't induce any bottleneck by it owns. Nowadays, every good database will already have a built-in caching mechanism. Yes, true, but at the end of the day it's network roundtrips and overhead that kills you. Depends. The pipes between the front computer and the database are usually not a problem. Plus, very often, an overhead is made of very few specific queries and my strategy is then to introduce a specific cache, rather than cache everything. Le jeudi 13 avril 2006 à 15:41 +0200, Dominik Bruhn a écrit : Hy, Nowadays, every good database will already have a built-in caching mechanism. so do you think that caching on the servlet-side is not needed and I should leave this task to the Database-Engine? This would simplify the whole task because I don't have to keep the caches on each server in sync. That's my point. BUT: Why is everbyody talking about caching? I think altough the Database-Servers might cache some data I still have to keep some of it in my servlets, at least those parts who are needed very often and change very seldom. Exactly. Velosurf has a caching option that you can set to true for the most needed entities. Claude - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to make #for thread-safe?
Le vendredi 07 avril 2006 à 21:27 -0700, Nathan Bubna a écrit : It would also preclude putting any singletons into the context. it precludes putting any *mutable* singletons in the context, and that's a good thing! i don't think mutable singletons are ever a good idea, especially in a threaded application like a webapp. they have big thread-safety issues. this will be true whether you use ASP, JSP, Velocity, or any other view technology. immutable singletons, on the other hand, are always thread safe in any application. some people still don't like them, but they won't have thread-safety issues. Isn't mutable singleton just a nice name for an ugly hack where you want a singleton to not anymore be a singleton ? -- Claude - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dynamically generated values
Hi. There are several solutions. 1. You can put the key/value pairs in a map that you put in the context: $catalog.get(entry_$id) 2. You can put the context inside itself $context.get(entry_$id) 3. A more generic solution is to use a render tool from the velocity-tools subproject. If you are using the VelocityViewServlet, you can use the ViewRenderTool : $render.evaluate($entry_$id) if not, then use the RenderTool; you will also need $context as in 2 $render.evaluate($context,entry_$id) -- Claude Le lundi 27 mars 2006 à 16:45 +0200, Thomas Peter Berntsen a écrit : Hi guys I'm using velocity to generate a 5x5 matrix with each entry having its own id like this: table style=border:1px solid black;z *#foreach* ($row in $rows) tr *#foreach* ($col in $cols) *#set*( $product = $col * $row ) *#set*( $id = $col$row ) td Row: $row, Column: $col br/ Number: $id /td *#end* /tr *#end* /table The template gets $rows and $cols, two int[]s containing values 1 through 5. The $id is a string concatenation of $col and $row. I am passing a key-value pairs - eg. (entry_15, FOO) to the template as well, where the key corresponds to the entry in the matrix in which the value should be shown. How do I accomplish this? I know that I would normally address the key to get the value like $entry_15, but the 15 is the dynamically generated value from the Velocity template itself (what is $id in the example above)... So I need something like $entry_#generateValue where #generateValue is a macro which precedes the $entry_. I've tried a lot of things, but it's all erraneous. I look forward to hearing from you. Cheers, Thomas - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dynamically generated values
Sorry. You should read $render.evaluate($context,\$entry_$id) and $render.evaluate(\$entry_$id) Claude if not, then use the RenderTool; you will also need $context as in 2 $render.evaluate($context,entry_$id) Le lundi 27 mars 2006 à 18:50 +0200, Claude Brisson a écrit : Hi. There are several solutions. 1. You can put the key/value pairs in a map that you put in the context: $catalog.get(entry_$id) 2. You can put the context inside itself $context.get(entry_$id) 3. A more generic solution is to use a render tool from the velocity-tools subproject. If you are using the VelocityViewServlet, you can use the ViewRenderTool : $render.evaluate($entry_$id) if not, then use the RenderTool; you will also need $context as in 2 $render.evaluate($context,entry_$id) -- Claude Le lundi 27 mars 2006 à 16:45 +0200, Thomas Peter Berntsen a écrit : Hi guys I'm using velocity to generate a 5x5 matrix with each entry having its own id like this: table style=border:1px solid black;z *#foreach* ($row in $rows) tr *#foreach* ($col in $cols) *#set*( $product = $col * $row ) *#set*( $id = $col$row ) td Row: $row, Column: $col br/ Number: $id /td *#end* /tr *#end* /table The template gets $rows and $cols, two int[]s containing values 1 through 5. The $id is a string concatenation of $col and $row. I am passing a key-value pairs - eg. (entry_15, FOO) to the template as well, where the key corresponds to the entry in the matrix in which the value should be shown. How do I accomplish this? I know that I would normally address the key to get the value like $entry_15, but the 15 is the dynamically generated value from the Velocity template itself (what is $id in the example above)... So I need something like $entry_#generateValue where #generateValue is a macro which precedes the $entry_. I've tried a lot of things, but it's all erraneous. I look forward to hearing from you. Cheers, Thomas - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Collect variables from a template
Hi. Maybe you can check the TemplateTool in the experimental section : http://svn.apache.org/repos/asf/jakarta/velocity/engine/trunk/experimental/templatetool/TemplateTool.java Claude Le mercredi 15 mars 2006 à 11:07 +0100, Holger Willebrandt a écrit : Hello everybody, i would like to parse a velocity template and collect information about all variables that are used within it. Therefore, i use the Parser class in the following way: //here a reader for the template and a collector for the variables //will be supplied public static void findVariables(Reader reader, List collector) throws ParseException { VelocityCharStream cstream = new VelocityCharStream(reader, 0, 0); Parser parser = new Parser(cstream); findVariables(parser.process(), collector); //call method below } //this method will recursively collect the variables and store them //in the collector. public static void findVariables(Node startNode, List collector) { if (startNode.getClass().equals(ASTReference.class)) { if (!collector.contains(startNode.literal())) { collector.add(startNode.literal()); } } for (int i = 0; i startNode.jjtGetNumChildren(); i++) { findVariables(startNode.jjtGetChild(i), collector); } } The code is working as long as the template does not contain a #foreach statement. Whenever i try to parse velocity code with a #foreach, i get the following error: java.lang.NullPointerException at org.apache.velocity.runtime.parser.Parser.Directive(Parser.java:628) at org.apache.velocity.runtime.parser.Parser.Statement(Parser.java:319) at org.apache.velocity.runtime.parser.Parser.process(Parser.java:258) Looking into velocity's source code, revealed that the Parser is missing a RuntimeServices instance, resp. a template name. It would be nice to have a way of collecting all variables and validating the synatx (a ParseException would indicate a syntax error) at once. Any kind of help or advice is welcome. Thanks, Holger - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Release of Velosurf 1.4
I'm pleased to anounce the release of Velosurf 1.4 About : Velosurf is a thin but efficient database mapping tool meant to be used with Jakarta Velocity. Its aim is to generate a set of context variables that automatically map database tables and relationships, without the need for any recomplation. Changes : The main purpose of this release is to allow the use of POJOs (Plain Old Java Objects) as row instances. Getters and setters of those POJOs are discovered using Java reflection. Homepage: http://velosurf.sourceforge.net/ List: http://lists.sourceforge.net/lists/listinfo/velosurf-devel Tarball: http://prdownloads.sourceforge.net/velosurf/velosurf-1.4.tgz?download -- Claude - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Release of Velosurf 1.4
Hi. Le dimanche 12 mars 2006 à 21:22 +0100, Tom Schindl a écrit : What's the difference to projects already existing like e.g. torque, which also uses velocity? (First, please note that Torque is using Velocity internally to generate its mapping classes, while Velosurf is meant to be use from within the VelocityTools toolbox but does not use Velocity itself since Velosurf doen't need any code generation.) The main difference between Velosurf and other database mapping layers is that Velosurf does not rely on persistence, which allows a more flexible object model where, for instance, you can define object properties as being SQL queries. Mike called Velosurf a direct view-to-database framework, but it's not quite exact since it provides a clear separation between the view and the object model - this separation is just thinner than in other relationnal database mapping libraries. And it's a tool, not a framework. I'm still quite surprised to note the ever growing usage of persistence frameworks like Hibernate. Today databases are very fast and well optimized, and IMHO the use of pertinence can only bring small gains in performance (while draining a lot of complexity in the same time). In a nutshell, Velosurf aims at being a small but efficient M in the MVC model. You should check http://velosurf.sourceforge.net/velosurf/docs/index.html for more details. -- Claude Claude Brisson wrote: I'm pleased to anounce the release of Velosurf 1.4 About : Velosurf is a thin but efficient database mapping tool meant to be used with Jakarta Velocity. Its aim is to generate a set of context variables that automatically map database tables and relationships, without the need for any recomplation. Changes : The main purpose of this release is to allow the use of POJOs (Plain Old Java Objects) as row instances. Getters and setters of those POJOs are discovered using Java reflection. Homepage: http://velosurf.sourceforge.net/ List: http://lists.sourceforge.net/lists/listinfo/velosurf-devel Tarball: http://prdownloads.sourceforge.net/velosurf/velosurf-1.4.tgz?download - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: VelocityServlet and Properties file
On Mon, 2005-10-17 at 09:28 +0100, Andrew Mason wrote: Thanks Wil, Where abouts is the WebappLoader located? I can't seem to see WebappLoader in the Velocity 1.4 API, the JDK Api or Tomcats Api. It's in the velocity-tools jar. -- Claude - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: for loops break?
On Fri, 2005-07-08 at 09:22 -0700, Will Glass-Husain wrote: no, unfortunately. Mwahahahaa, once you're trapped inside, there's no way out (br it's freezing...) -- Claude WILL - Original Message - From: Jean Francois Chamard [EMAIL PROTECTED] To: velocity-user@jakarta.apache.org Sent: Friday, July 08, 2005 8:53 AM Subject: for loops break? Hi there, been using velocity for a while now. Is there a way to get out of a loop? Perhaps it has been asked but I found nothing on the subject (guide, wiki, ...). If there is, sorry about it. Is there a way to do something like that? #foreach( $mycounter in [10..1] ) #if ($mycounter == 5) break; ? #end #end I've used velocity 1.4 but i'm now with 1.5 dev. Thanks for your answer JF - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Help me - how to pass retreived database values to Javascript
Once again, please post your questions on the users list. Plus, be kind enough to write a new mail instead of replying to a mail from another thread. Velocity is server-side, Javascript is client-side, so they cannot interact. What you can do is generate Javascript code using Velocity. -- Claude On Thu, 2005-06-23 at 07:31 -0600, Veerappan Sridhar wrote: Hi, Pls help how i can get the database values in javascript. I got list of values retrieved from backend and stored in arraylist like $alroles, so now i can pass these values to javascript and access. Scenario: i have n number of text box,the text box(i) contains some values that values should be checked with the backend values for that i need a function to pass and compare in javascript. So pls help me Thanks Sridhar - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Velosurf 1.3.1 released
I'm pleased to anounce the release of Velosurf 1.3.1 About : Velosurf is a thin but efficient database mapping tool meant to be used with Jakarta Velocity. Its aim is to generate a set of context variables that automatically map database tables and relationships, without the need for any recomplation. Changes : This release fixes two problems with ID obfuscation: the character set of obfuscated strings does not anymore contain any sensible HTTP character, and lastInsertID is now obfuscated as needed. Homepage: http://velosurf.sourceforge.net/ List: http://lists.sourceforge.net/lists/listinfo/velosurf-devel Tarball: http://prdownloads.sourceforge.net/velosurf/velosurf-1.3.1.tgz?download -- Claude - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: velocity tools init
exactly. -- Claude On Tue, 2005-03-15 at 10:36 -0500, Charles N. Harvey III wrote: Hello. Quick question about some of the Velocity Tools. How come the Struts Tools and View Tools implement ViewTool and have an init() method but the generic tools do not? How do they actually get initialized? Do I have to just do new DateTool() and it works? It seems like it, but I just wanted to double check. Thanks a lot. Charlie - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Freemarker comparison - macro recursion
On Thu, 2005-02-24 at 20:07 +0100, Meikel Bisping wrote: Of paramount importance for me is possibility to invoke a macro recursively. Can you do that with Velocity? yes of course, but it's usually easier to handle on the java side (you can have a little tool that enumerate the leaves of a tree for instance). if you still think recursion is your way, it's easier with the #local macro (which is not included by default, it should be somewhere in a subversive whiteboard), which role is to protects the variables namespace inside each level of recursion. -- Claude - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Velocity and JDBC
On Wed, 2005-02-23 at 12:39 +0200, Markos Charatzas wrote: Hm... Im quite skeptical about this... Why not use a proper OR mapping tool (e.g. hibernate), provide a complete db implementation (Database, DatabaseRequest, DatabaseClient) and then use a db client wrapper to place as a tool using the velocity toolbox. What do you mean by proper? bigger? ;-) do you really mean that hibernate + a wrapper tool would be a proper solution? just curious... Claude - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Velocity and JDBC
On Wed, 2005-02-23 at 16:52 +0200, Markos Charatzas wrote: Well ofcourse it depends on the scale of the application. precisely, not necessarily If you want something quick and dirty you can do it with Velosurf no probs. yes, you can - but even in large applications I'm not totally certain that the choice of Hibernate is always pertinent (it depends if you really need persistence or not). Hence, Velosurf can be a clean choice. I was just trying to alert ppl who might jump straight to the Velosurf wagon to support their database driven application. seems fair Claude Markos On Wednesday 23 February 2005 14:51, Claude Brisson wrote: On Wed, 2005-02-23 at 12:39 +0200, Markos Charatzas wrote: Hm... Im quite skeptical about this... Why not use a proper OR mapping tool (e.g. hibernate), provide a complete db implementation (Database, DatabaseRequest, DatabaseClient) and then use a db client wrapper to place as a tool using the velocity toolbox. What do you mean by proper? bigger? ;-) do you really mean that hibernate + a wrapper tool would be a proper solution? just curious... Claude - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Help Me To Integrate Java Applet And Velocity Template
On Sat, 2005-02-19 at 01:20 +, Miguel Angel García Santiago wrote: I´m trying to seek info about the integrate a java applet with velocity template but not find, anyone will help me please? search infos on how to integrate a java applet with html, it's the same -- Claude - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: getting template from string
Hi. On Fri, 2005-01-28 at 11:39 -0800, sunil goyal wrote: Hello all, I am using Velocity within some servlets(VelocityServlet). VelocityServlet is deprecated. You should use VelocityViewServlet, from the tools subproject. I want to get a template from a String rather than a file. I am not able to find the appropriate function for that. For getting a template from file, there is a method called Template getTemplate(String path) in VelocityServlet. I am storing small template files as String in a database, and want to construct template from that string. Template getTemplateFromString(String data) or an InputStream ? You can check the VelocityEngine.evaluate method http://jakarta.apache.org/velocity/api/org/apache/velocity/app/VelocityEngine.html -- Claude -- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Many calls to init(Object o) in tool extending ViewTool in request scop
On Thu, 2005-01-20 at 14:15 -0500, Matt Higgins wrote: The subject explains most of it.. I have a simple print line in the init function of my tool. On every page I hit .. including pages that don't use the tool (This makes some sense to me), the init function is called 22 times. This seams strange and wrong to me? This leads me to believe that every tool in the request scope will have similar behavior??? This is quite a bit of over head. I am using Velocity with Struts / Tiles if that makes a difference. Is there any way to stop this? Am I using the tool box inappropriately? Any suggestions would be helpful. My suspicion is each tile is somehow generating a new request? If this is true is there a way to avoid this? -Matt The normal behaviour is one request per page/frame and one instanciation of request tools per request. If this is not what you observe, you can investigate. Your suspicion is true only if Struts/Tiles, which I don't know, is implemented using frames/iframes. I take profit of this mail to let us speak a bit about tools (more for devs). We spoke before about tools pooling (especially Nathan iirc): how can it be implemented? Using a Reusable interface with a reinit(initdata) method? And a suggestion on the same subject: Maybe we could have the syntax of the scope element be: application | session | request | url regexp in toolbox.xml to refine scopes at a thiner level than the request scope. Claude -- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: bug velocity installation
On Tue, 2004-12-21 at 19:48, Philip Mark Donaghy wrote: I'm sorry that's not it. The source code includes variables named 'enum' which is a keyword in jdk1.5, try uninstalling jdk1.5 and installing jdk1.4, then rebuild. Phil yes, Velocity does currently not compile under java 1.5 you can either download a compiled version, or edit the build.xml file to give arguments to javac like : javac -source 1.4 -target 1.4 Claude - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Announce : Will Glass-Husain as Committer
Congrats, Will! Claude On Wed, 2004-12-15 at 15:40, Geir Magnusson Jr. wrote: It is with great happiness that I can announce that Will Glass-Husain has been elected a Velocity committer. I've known Will for some time now, both online and in the real world, and it's been great to see his interest in Velocity develop from dedicated user - his business depends on it - to general benefactor, interested in and understanding of all the facets of Velocity that generally have me considered to be a cranky old recalcitrant conservative. As one of the Velocity founders was fond of saying Thanks for volunteering And welcome. geir - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: template location question
On Tue, 2004-12-14 at 11:05, Geercken Uwe wrote: hello everybody, I have developed a web application using the velocitylayout servlet. works fine and I am very happy with velocity. but one thing I would need your help on. I currently have all my templates in one folder eng/templates (where eng means english). I would like to be able to allow the user to switch to a different language, so that now the folder e.g. de/templates is used. I use a central controller servlet that extends the layout servlet. what do I need to do to change the location of the templates dynamically from the web application. If you maintain the current language as a parameter in the user's session, you can omit the language prefix from the url and have an overloaded method getTemplate in your controller servlet that prefix the current language to the path found in the url before calling the super one. Claude - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problems with ViewRenderTool
On Fri, 2004-12-10 at 22:14, Nadesan, Binu wrote: The problem lies with the statement $render.eval($e.$text) Here $e is an object and $text contains a string value that is a property of the object. try with : $render.recurse($e.$text) because what you really want is eval(eval($e.$text)) Claude - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [FAQ] How do you check for null?
On Fri, 2004-12-03 at 23:36, Shinobu Kawai wrote: Note : The template designer has to be some kind of mathematician to understand what they're doing. ;) Imagine how simple it would be with the 'null' keyword... which makes another good reason to include it ! We often spoke of the interest of this new keyword as a mean of passing a null value to a method or to set a reference to null, but this third usage is also interesting. Claude - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: XML and velocity
On Thu, 2004-12-02 at 12:48, Subbiah Raman wrote: Hi, I am trying to use a SAX parser in Velocity context and I need to do the following #set($temp = $root.getRootElement().getChild(email).getText() ) But it throws org.apache.velocity.exception.ParseErrorException: Encountered email There's an unclosed in your statement. Also, you can simplify the syntax of the getters that take no argument. Try : #set($temp = $root.rootElement.getChild(email).text ) Claude - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Detect ReferenceException
Hi. On Thu, 2004-11-25 at 00:22, Matthew Keene wrote: I'd like to be able to detect ReferenceExceptions (and other errors) that happen during a merge operation. At the moment they appear in the velocity.log, but I'd like to be able to display them to the user. At the very least I'd like to be able to detect that they have occurred so that I can put up a message telling them to check the log for error details. So far I've been unable to work out how to do this, can anybody give me any pointers ? Some errors do throw up exceptions, others don't... For the former (like parse errors), you only have to catch them in your servlet, then you can display the error to the user. For the latter, it's more difficult... Typically, they are null #sets and invalid references. For null #sets (i.e. when you try to set a reference to a right-hand value that evaluates to null), there is a NullSetEventHandler but... you can't do much from inside the event handler (which only real purpose is to say if you want it to be loggued or not...), apart from... throw a RuntimeException (ouch!) or dwell with ThreadLocal objects... For invalid references that's easier : you can use a ReferenceInsertionEventHandler and check for null values from here. If you encounter null values, you can decide to return a bright red error tag in html that'll appear in-place in the rendered page. Last but not least, I must mention Will's patch http://issues.apache.org/bugzilla/show_bug.cgi?id=28388 that allows one to declare event handlers from within velocity.properties, among other things. I hope it will be included in version 1.5. Hope that'll help Claude - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Localized data: best practice - insights appreciated
Hi On Wed, 2004-11-24 at 17:35, Simon Christian wrote: I don't know is this would count as a 'best practice', but how about using a ThreadLocal on each request to hold the Locale of the visitor. Then the Product (for instance) would be able to find the Locale all by itself and return the appropriate String. I notched up a little example doing this using a Servlet Filter to capture and store the Locale (which I hope doesn't line-wrap too badly): [...] You should then be able to access the Locale by just calling LocaleFilter.getLocale() from within the Product or elsewhere. 'elsewhere' can be a custom ReferenceInsertionHandler (see http://jakarta.apache.org/velocity/developer-guide.html#EventCartridge%20and%20Event%20Handlers). If the methods Product.getTitle() and co. return ids as an identifiable string, like locid_1234, or -much better- as a specific class, your handler can convert such strings on the fly : 1. Velocity renderer encounters $product.title 2. Product.getTitle() returns LocalizedString(1234) (where LocalizedString is just a wrapper around an ID) 3. your LocalizationHandler watches for LocalizedString and uses the LocaleFilter.getLocale() and the DB to find the appropriate String (or delegates all this stuff to a Localizer via a static method getString(LocalizedString,Locale)) and returns it to the renderer. Just an idea, hope I made it clear... Claude - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Velocity alternative for WebMacro's Template.getParam?
If I understand correctly, it's a way to ask a template for its needs on the java side, before merging it with a context. Interesting. One way I think of would be to traverse the nodes of the parsed template and make a distinct count of the ASTReferenceNode nodes. Something like : public List getParameters(Template template) { Node rootNode = template.getData(); List result = new ArrayList(); return getTreeParameters(rootNode,result); } public List getTreeParameters(Node node,List list) { if (node instanceof ASTReference) { // we lack a ASTReference.getReferenceType() method String ref = ((ASTReference)node).getRootString(); // don't take into account bad references if (ref.indexOf('$')!=-1 || ref.indexOf('!')!=-1) { return list; } if (!list.contains(ref)) { list.add(ref); } // don't traverse children of a ASTReference, // since if present, they follow a dot } else for (int i=0;inode.jjtGetNumChildren();i++) { list = getTreeParameters(node.jjtGetChild(i),list); } return list; } (neither compiled or tested...) Claude On Mon, 2004-11-15 at 09:32, Stefan Rotman wrote: Hi, I'm checking out the possibility to migrate some of our WebMacro projects to Velocity. Now there's one thing that we use a lot in WebMacro, for which I can't find a Velocity alternative just yet. We use the Templage.getParam function from WebMacro to get some parameters before parsing the template. Javadoc at: http://www.webmacro.org/api/org/webmacro/Template.html#getParam(java.lang.String) Let me explain with a little example: We have a WebMacro template (let's call it template.wm) looking like this: html body #param $require = [foo, bar] Foo value is $foo Bar value is $bar /body /html Now when our servlet is instructed to return the template.wm Template, the code looks somewhat like this: public class FooServlet extends WMServlet { public Template handle(WebContext context) { Template template = getTemplate(template.wm); Object[] requiredParams = (Object[])template.getParam(require); for (int i = 0; i requiredParams.length; i++) context.put(requiredParams[i], -Value for +requiredParams[i]+-); return template; } } This way the values for foo and bar are known when the template is displayed. Is there a right way to do this in Velocity? The closest I came to this using Velocity is creating a new VelocityContext, merge the Template with this context, and get the value for require from that context, but when doing this I get warnings in my log files about $foo and $bar that are not yet set, so I really would like a cleaner way to do this. Thanks in advance, Stefan. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: trouble creating a local Map
You need to use the CVSHEAD version of velocity to use map declarations. Claude On Mon, 2004-11-15 at 23:17, Rob Hoexter wrote: Velociteers: I am attempting the simple task of creating a Map variable, and am having trouble with the syntax. Using the pattern exactly as in the example in the User Guide: #set ( $test.Map = {argh : one, blah : two} ) ^ | I get a lexical error cryptically labeled (123) on the first { character. It appears that the syntax isn't recognized. Does anybody know what it is supposed to be? Thanks, Rob Hoexter, UI Architect CaseCentral, Inc. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: VelocityEngine.init(Properties p) not working
All the default properties are visible through the application properties object using either the props.propertyNames() enumerator or a props.getProperty() call. How is it possible that VelocityEngine cannot see these properties? There is no way to distinguish between the two types via the Properties API (as far as I can tell) - they should all look the same to velocity. It looks like a possible bug in o.a.c.collections.ExtendedProperties. Velocity uses this class instead of java.util.Properties. It calls ExtendedProperties#convertProperties() to convert the properties, but this method uses Properties#keys() to transfer the values. This is equivalent to HashTable#keys(), which has no reference to the default properties. That's right. You should check your version of jakarta-commons, and maybe upgrade to the latest release. Claude - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ant DVSL task can't find VM_global_library.vm
On Tue, 2004-11-09 at 22:43, Larry Siden wrote: I have written the following ant task [...] In particular: C:\Views\lsiden_view_2\sdm_svc\SDMservices\GKN\Phase2\DeveloperRepository\veltemplate\VM_global_library.vm : org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource However, this is exactly where VM_global_library.vm is found on my system! What am I missing? Not sure it is related, but I already had problems with backslashes and ant : the same build was working on linux, but not on windows... Update ant and try again ? Claude - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [ANN] VelocityTools 1.1-rc1 released
Nice. Maybe one of those two identical mails was intended to the velocity-users list, wasn't it ? BTW, I noticed VelocityTools is not listed on Freshmeat. Maybe it should, visibility is never bad... CloD - Original Message - From: Nathan Bubna [EMAIL PROTECTED] To: [EMAIL PROTECTED]; [EMAIL PROTECTED]; Velocity Users List [EMAIL PROTECTED]; Struts Users Mailing List [EMAIL PROTECTED] Sent: Sunday, February 22, 2004 8:12 AM Subject: [ANN] VelocityTools 1.1-rc1 released I'm pleased to announce the release of VelocityTools 1.1-rc1. Improvements since 1.1-beta1 include: -Refined and completed TilesTool and ValidatorTool. -Addition of NumberTool for number formatting. -Improved documentation of the newer tools. -Examples of new VelocityStruts tools and features. -Further improvements to MathTool DateTool. -New recommended keys for MessageTool and ActionMessagesTool. -Several miscellaneous bug fixes. For a more detailed list of changes see: http://jakarta.apache.org/velocity/tools/changes.html Downloads: Binaries: http://jakarta.apache.org/site/binindex.cgi Source Code: http://jakarta.apache.org/site/sourceindex.cgi For more information on Jakarta Velocity Tools, see http://jakarta.apache.org/velocity/tools/index.html Nathan Bubna [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [ANN] VelocityTools 1.1-rc1 released
Maybe one of those two identical mails was intended to the velocity-users list, wasn't it ? sorry, ignore... aleas of my sorting rules... CloD - Original Message - From: Claude Brisson [EMAIL PROTECTED] To: Velocity Users List [EMAIL PROTECTED] Sent: Sunday, February 22, 2004 5:14 PM Subject: Re: [ANN] VelocityTools 1.1-rc1 released Nice. Maybe one of those two identical mails was intended to the velocity-users list, wasn't it ? BTW, I noticed VelocityTools is not listed on Freshmeat. Maybe it should, visibility is never bad... CloD - Original Message - From: Nathan Bubna [EMAIL PROTECTED] To: [EMAIL PROTECTED]; [EMAIL PROTECTED]; Velocity Users List [EMAIL PROTECTED]; Struts Users Mailing List [EMAIL PROTECTED] Sent: Sunday, February 22, 2004 8:12 AM Subject: [ANN] VelocityTools 1.1-rc1 released I'm pleased to announce the release of VelocityTools 1.1-rc1. Improvements since 1.1-beta1 include: -Refined and completed TilesTool and ValidatorTool. -Addition of NumberTool for number formatting. -Improved documentation of the newer tools. -Examples of new VelocityStruts tools and features. -Further improvements to MathTool DateTool. -New recommended keys for MessageTool and ActionMessagesTool. -Several miscellaneous bug fixes. For a more detailed list of changes see: http://jakarta.apache.org/velocity/tools/changes.html Downloads: Binaries: http://jakarta.apache.org/site/binindex.cgi Source Code: http://jakarta.apache.org/site/sourceindex.cgi For more information on Jakarta Velocity Tools, see http://jakarta.apache.org/velocity/tools/index.html Nathan Bubna [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [ANN] VelocityTools 1.1-rc1 released
Nathan wrote : actually, it is. :) http://freshmeat.net/projects/velocitytools/ I was talking about the anouncement - isn't it the way for subscribers to acknowledge new versions ? but it's maybe not important for RCs and when we went 1.0, i even got a blurp on slashdot (go figure.) http://apache.slashdot.org/apache/03/07/17/1425228.shtml?tid=148tid=185 yes, I saw, that's cool CloD - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Double indirection impossible?
alas, no but the tools subproject has a RenderTool (and a ViewRenderTool if you use the VelocityViewServlet) with which you can evaluate strings by the way, why should Velocity support -or not- indirection ? The reason why it should not : it might break the Keep It Simple Stupid paradigm - so some say. VTL would look like Perl, according to them. The reasons why it should be supported, IMO : 1. By language self-consistency : not having indirection is typically a constraint that any developper wandering around with Velocity will stumble over one day, after having tried it, thinking it will work. 2. Since you've got an easy workaround by mean of a tool, why not having it as part of the syntax. 3. Should VTL allow indirection, templates are not gonna fill themselves with ununderstandable $$ - I mean it will be a marginal - but very practical - usage. Just some thoughts. CloD - Original Message - From: J. B. Rainsberger [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: vendredi 14 novembre 2003 16:54 Subject: Double indirection impossible? Everyone: I was unable to find a definitive answer to this question in the documentation, so I'll ask here. I suspect this is a FAQ. I apologize. Does Velocity support double indirection? I mean evaluating a reference to a reference... ${${fieldName}} ...where the value of fieldName is a valid member of the current VelocityContext. Is there any way to achieve this? Without it, I have to give up some important refactorings, and I'd rather not. Thanks. -- J. B. Rainsberger, Diaspar Software Services http://www.diasparsoftware.com :: +1 416 791-8603 Let's write software that people understand - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Map patch in
Congrats, you are really back ! :-) Remark : the current map syntax is not ok, since there is no way to disinguish an empty map and an empty array current syntax : #set( $map = [key1 : value1, $key2 : $value2] ) I thought we were going to use { } (how do you call them in english ? curly braces or something no ?) CloD - Original Message - From: Geir Magnusson Jr. [EMAIL PROTECTED] To: Velocity Developer's List List [EMAIL PROTECTED]; Velocity List [EMAIL PROTECTED] Sent: jeudi 23 octobre 2003 16:03 Subject: Map patch in I put in the patch from James for the Map support. Give it a whirl. -- Geir Magnusson Jr 203-247-1713(m) [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: problems hooking event handlers in with EventCartridge
Nathan Bubna wrote : 3) Is there any way to #parse() a template that isn't in the current directory or subdir? you should be able to give #parse() a relative path. so #parse( '../otherdir/foo.vm' ) ought to work (i do this in some of my apps). It is luck if it worked for you, because according to the actual code, it's not handled at all. I've implemented it in a first hackish patch (that I posted under bugzilla #18072), and then in a much cleaner patch that I will submit the day contributions get a chance to be commited (since it involves patching the core...). This new patch allows the WebappLoader to have several pathes, along with the possibility for those pathes to be relative. So now I can write : webapp.resource.loader.path = /WEB-INF/templates webapp.resource.loader.path = . webapp.resource.loader.path = / and my templates are searched successively in /WEB-INF/templates, in the current path (for #include or #parse), and then from the webapp root. Cool, isn't it ? If someone is interested I will send him the patch. CloD - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Newbie: returning a reference to a List
Try : #set ($availableCars = $Inventory.getAllCars($mfr, $model, $cars.CT_MANUAL)) Also, you can write : #set ($car = $Driver.car) #set ($mfr = $car.manufacturer) #set ($model = $car.model) CloD - Original Message - From: Scott Chun [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: samedi 1 mars 2003 00:14 Subject: Newbie: returning a reference to a List I'm getting the following error message when attempting to set a variable with a List type. [error] RHS of #set statement is null. Context will not be modified. view.vm [line 29, column 8] #set ($car = $Driver.getCar()) #set ($mfr = $car.getManufacturer()) #set ($model = $car.getModel()) #set ($availableCars = $Inventory.getAllCars([$mfr, $model, $cars.CT_MANUAL])) ##= error line $Driver is supplied by the servlet by: ctx.put(Driver, driver); getManufacturer() returns a String getModel() returns a String CT_MANUAL is defined as: public static final int CT_MANUAL = 1; getAllCars(String, String, int) returns a List of all available cars that match the specifications. Does this code even make sense? Thanks in advance! -- This message may contain confidential information, and is intended only for the use of the individual(s) to whom it is addressed. == - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]