Post by Håvard Wahl KongsgårdThanks, but is it possible to integrate SQL with FreeMarker?
Well, if you put a JDBC Connection or DataSource into the data-model,
I'm certain FreeMarker's reflection support's enough for issuing
queries... But I would not recommend that, as it's awkward and all.
The FreeMarker-ish way is writing a (few) TemplateDirectiveModel
implementations instead, something that you could use like this for
example:
<@sqlExec "INSERT INTO foo(X, Y) VALUES(?, ?)" x y />
<@sqlSelect "SELECT id name FROM foo"; row>
... ${row.id} ... ${row.name} ...
</@sqlSelect>
For that you write a TemplateDirectiveModel and put that into the
data-model with name "sql", or pull it into an #imported/#included
file with <#assign sqlExec = "com.example.SqlExecDirective"?new()>.
Still, data-base modifications should clearly be done outside the
template according the MVC principles, in the Controller.
Post by Håvard Wahl KongsgårdI use geoserver(FreeMarker is the template engine). I only need to
do some simple inserts from a form to a postgresql database.
-Håvard
Post by Daniel DekanyFreeMarker just generates text (like HTML, JavaScript, whatever) on
the *server* side. So of course you can have AJAX, jQuery etc. on your
FreeMarker-generated web pages. But mind you, JavaScript runs on the
*client*, and hence after FreeMarker was generated the page.
You can't (or shouldn't) use FreeMarker on the same way as you use
PHP. With PHP you do all the program logic including the presentation,
while with FreeMarker you do the presentation only. FreeMarker is for
MVC frameworks, where it's used for the MVC View. Do the non-View
programming in Java, Groovy, Scala, or whatever you prefer, but not in
FreeMarker. (Or if you don't need MVC, you don't want to use
FreeMarker.)
Hi, without success, I experimented with including simple Javascript
Ajax code interacting with a PHP site in freemaker templates.
example
http://yensdesign.com/2009/01/create-a-shoutbox-using-php-and-ajax-jquery/
With the current version of freemaker is it possible to include this
type of code in freemarker templates?
--
Best regards,
Daniel Dekany
--
Best regards,
Daniel Dekany