You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Keith Cheng <mr...@yahoo.com> on 2002/10/17 16:14:08 UTC

String manipulation and other handy tools

Dear all,

I am very new with Velocity and what I am looking for is a tool that helps me to generate various files that are based on a same source in my Struts application, e.g., I want to generate value (bean) classes and database table sql from a single source (xml file).  

Then I tried "Anakia" but I hit a problem that I can't "upper" the first letter of the "column" name for the "setter" in the corresponding bean class, e.g.: firstName is the column in the User tables and its corresponding stter in the class User is setFirstName ()!  It should be easy to just "upper" the first letter of the column name but there is NO such tool in Anakia.  I look at the code and I found that I can put a custom "String Utility" in the context.  But this makes me a bit disappointed since I just want some handy tool to generate source files and not prepare to write any "real" code.  I expect that VTL can handles this.

I may miss out some function that Velocity can help me to solve the problem, please tell me if any one know the trick.

BTW, if there is NO such trick and requires me to write java code (in the Anakia case, I have to change the source code!), than may I propose Velocity to add:

1, How about a default String manipulation tool in context?  I am not sure whether this breaks the MVC model BUT Velocity seems not only working for "MVC", just like my situation, I am not using Velocity in an application but just generates some source files.

2. How about adding a configuration or directive that allows user to add "context tool class"?  Something in the config file or even inside template file like <contextTool class="com.mycom.util.StringUtil"> or #ContextTool="com.mycom.util.StringUtil"?  So that I don't need to inject my codes into tools like Anakia.

(PS: I also look at another tool Torque and it is also based on Velocity and closed to what I want but NOT exactly.)

Thanks for your time.

Cheers,

-- Keith Cheng

1874(陳奕迅),再見露絲瑪莉(何韻詩),傷逝(葉倩文)...
越800首至新至Hit手機鈴聲!
Over 800 latest ringtones, only on Yahoo!