cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Heiden <>
Subject Re: jXtemplate and Java source: searching an example or tutorial
Date Sat, 23 Aug 2008 21:34:34 GMT

Saturday, August 23, 2008, 9:19:13 PM, you wrote:

j> What I want for my project is to use real lines of Java source in the
j> jXtemplate file: like it was in XSP. Is this possible.

j> For instance, the next line:
j>     String name;
j> There are other possibilities in jXtemplate to have a variable "name". But I
j> use this as an example. The question is: can someone give me an example on
j> how to use this line in jXtemplate? Just something like this (beaucause the
j> Java source I will use will be more complex):

If your Java code is complex it shouldn't be part of a view.
JXTemplate offers you all you need for the "view logic" you can
iterate over collections, you can use conditional statements and even
calculate. But if you need more complex logic, you should separate
it. JXTemplate enforces you to do so, and I think that's a good thing.

Take a look at:

If you need more complex logic you must decide to what kind of logic
it belongs. If it is "controller logic" (for example a decision which
view should be shown to the user), you should code it as flowscript
(or Javaflow). If it is "business logic" (for example a complex
calculation or database access" you should code it as a plain old
Java Object (POJO) and make that a Spring Bean. Than you can access
it by flowscript and pass a result object or even the Spring Bean to
the template and output the data.

This sounds more complex, but if your application grows, it will be
much easier to maintain and you can reuse the code in other
applications. It's really worth to do it this way!



To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message