Re: Teething troubles

Tim Pizey <[email protected]>
Newsgroups gmane.comp.web.freemarker.devel
Message-ID <CAArDntibE-TANkwW7nnZ4voOMsY40QDszEqu7u07fCUPMYR-Lw@mail.gmail.com>
Hi Daniel,

First thank you for both your quick responses.

On 8 March 2012 19:39, Daniel Dekany wrote:
> Thursday, March 8, 2012, 6:52:33 PM, Tim Pizey wrote:
>>
>> I have used the binary cavalary.jar from
>> http://freemarker.sourceforge.net/usCavalry.html
>> to convert my velocity templates.
>> This has left me with Velocity style variables eg
>> ${table.TableInfo.Category.Name}
>>>From the above page: "Also note that FreeMarker uses the Java built-in
>> Beans introspection, so - contrary to Velocity - it completely adheres
>> to introspection rules."
>
> It's the mistake of usCavalry, I suppose. It should be
> ${table.tableInfo.category.name}
>
>> It also converts colours into tags: <body bgcolor="<#call dddddd>" id="top">.
>
> I guess that's because the *Velocity* parser thinks #dddddd is a macro
> call. But when it doesn't find such a macro on runtime, it just prints
> #dddddd. But the translator tool can't decide that no such macro will
> be available on runtime (or can it?), so probably it should use some
> heuristics to spot color codes.
>
>> I am unable to contribute fixes as this code is not in the source tree.
>
> I don't know where the source code is either... The tar.gz contains
> two .java-s, yes. But I think the tricks happens inside
> org.apacahe.velocity, that Jonathan has patched, and I don't see that
> patch anywhere. It's my quick conclusion anyway.
>
> There's also a tools/vel2ftl in the SVN repo. I have no idea what's
> that, or if it works... But it surely doesn't look like usCavalry.
>
> I will have to ask Jonathan...

On 8 March 2012 22:37, Daniel Dekany <[email protected]> wrote:
> The author of usCavalry says he doesn't know where the source is...
> So, the best is probably trying tools/vel2ftl from the SVN repo.

Thanks.

>> So my current hope is to modify BeansWrapper to understand Velocity
>> style bean notation.
>
> Don't do that... BeansWrapper uses standrad JavaBeans rules. Changing
> that would be rather annoying for anyone who wants to work with the
> templates later.

Sure, I do not intend to replace, but to extend into my own VelocityBeanWrapper.
(though I think there may be others who would like to be able to use
both Sun and
Velocity method notation)

>> I have checked out the source: in Eclipse I had to change the
>> configuration to only warn on restricted access.
>
> Um... what's that again?

Apparently since java 1.5 overriding methods from classes in RT.jar
gives a problem. This can be overridden in eclipse by settting
Preferences> Java>Compiler>Errors/Warnings>Deprecated and Restricted
API> Forbidden reference(access rules) to warning rather than error.

>> Building from source
>> I documented my fix for ant/ivy on ubuntu at:
>>
>> http://stackoverflow.com/questions/1066976/building-freemarker-from-source
>
> The current production version of FreeMarker, 2.3.x, with doesn't use
> Ivy. Please use the SVN repo, not GIT. GIT contains 2.4, which is
> unreleased.

I was building from
https://freemarker.svn.sourceforge.net/svnroot/freemarker/trunk/freemarker
so I should be using
https://freemarker.svn.sourceforge.net/svnroot/freemarker/branches/2.3/freemarker

>> My main motivation is to be able to use beans such as
>> ${table.TableInfo.Category.Name}  to access a java object which I have
>> placed in the root (context)
>> with a name of table and for
>> table.getTableInfo().getCategory().getName() to be discovered in that
>> object.
>>
>> Which direction should I turn?
>
> This has to be fixed in the converter. I'm not sure if I can contact
> Jonathan (the author) and that he will do anything within a reasonable
> time frame. So... maybe you should just do some regexp magic and
> replace those capital letters after the dots. I don't know how many
> templates do you have, however. But I'm certain nothing will translate
> Velocity to FreeMarker perfectly... a tool may saves you from most
> mechanical work, but you still will have to go through the templates
> and change this and that, unless the Velocity templates were extremely
> simple.

thanks again for all your advice
Tim






-- 
Tim Pizey
http://pizey.net/~timp

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
FreeMarker-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.