Re: got tired of waiting for IDE support - new tool to preview FreeMarker templates
Jeromy Evans <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Organization | Blue Sky Minds Pty Ltd |
| Message-ID | <[email protected]> |
Jonathan Revusky wrote: > > By the way, Jeromy, your thing is a servlet, isn't it? DId you think > about doing an applet? > > It's a struts2 application that sits behind a filter. The filter simply dispatches requests to an appropriate pojo and handles all the mundane processes like parameter mapping and javabean->json serialization. Excluding libraries, there's actually not much code on the server-side. A nice aspect of this approach is that the template engine is just a service that's accessible to any UI that can post to it. In this case it returns a json structure but it could just as easily return strongly-typed xml if the client asked for it. I threw this app together from a lot of existing code. The bulk of effort is in the javascript. > The reason I ask is that I had been thinking about putting my VTL->FTL > syntax converter on the web and for the longest time, I was thinking > in terms of a servlet, but then I remembered that applets existed. I > swear I think I had forgotten about them. Though it turned out that > putting that in an applet is hard because I was using Velocity to > build the VTL tree, and it is awfully hard to just get Velocity to > parse a file without having it try to start up a whole "engine" that > tries to read files all over the place and so on. And that runs into > all these applet security exceptions. I would have to get in there and > cut away all that stuff. Not so hard, but time consuming and I left it > for later. > > I wouldn't build an applet for a tool like they have too many limitations. If I wanted something applet-like instead I'd build an application using Swing (or another gui library) and make it Java WebStart-able. It would have the strengths of that library while being able to be launched from a browser or desktop. It gives the developer better control over the security (but doesn't take away all the pain). Applets are okay for rich widgets embedded within a webpage (like an image uploader) but not so much for a full-screen app compared to the alternatives (foolishly Sun lost that market to flash, and now flex). My own interest at the moment is in javascript-based interfaces. This application is built in YUI. > OTOH, the other conversion thing I have in the works is switching > between FTL syntaxes, from the angle brackets to square brackets. I > have a converter for that and I could put that in an applet, it just > occurs to me, pretty easily. And I think that a converter that > generally just gets rid of all deprecated constructs and replaces them > by the approved one would be a good thing to stick on the web. Also, > an applet that just shows a template's output looks like a pretty > useful thing, but it again runs up against the problem of defining the > data model to use. > > If I was doing this I'd write the converters in the usual way and then wrap them in services that can be accessed via http. That would be pretty straight-forward with any modern web framework. Then the effort would go into the front-end, which could be a simple html form, or reusing something like my javascript front-end, or finding someone to create a flash version, or all of the above. > BTW, I don't know where you're maintaining your code for this. If you > want to put it in our SVN, you are quite welcome to maintain it there. > Probably initially in the sandbox directory. > > I can't do that immediately as it's dependent on many of my own libraries. I'd support creating more online FreeMarker tools like you've described though. There doesn't seem to be enough hours in the day any more. regards, Jeromy Evans ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone