Holger Benl wrote:
Interesting - just 2 days ago I thought "if only I had JSP without http".
I'm using JSP to generate FO, which is OK since I'm using it in a web
application. But now I'd like to use the same solution outside of a
web container...

One solution could be "Pagelets" 
(http://www.urbancode.com/products/pagelets/index.jsp)
Quote: "The idea and functionality behind Pagelets is very similar to Java 
Server Pages
with one huge difference - Pagelets are not tied to the HTTP protocol."
It's not open source though. And it doesn't seem to support taglibs (which is my
personal favourite JSP feature).

Another solution would be to take an open source JSP compiler (e.g. Tomcat's 
Jasper) and
either teach it to generate code that doesn't depend on 
HttpServletRequest/Response/...
or make the generated code use some dummy implementations of the HttpServlet* 
interfaces.

Great minds think alike... I also first googled Pagelets and then taught of Tomcat's Jasper.

Shouldn't be too hard, but I'm afraid I won't have the time to do it.

Me neither :( But I do believe it's hard: think of tag libraries and the predefined variables in JSP's and request/sessions/application scopes tied in.



But it should go a few steps further:
- decent support for instance variables and methods: to be able to do real dependency injection and treat them as "services".
- ability to implement interfaces
- decent support for method parameters and local variables: to be able to pass the domain objects as a parameter to the service call.


So I am thinking about doing it radically different by combining java and jsp's to generate a java file which then compiles. Something like:


/src/main/template/PersonPrintImpl.java
=======================================

public class PersonPrintImpl implements PersonPrint {

   private PersonService personService;
   public void setPersonService(PersonService personService) {
       this.personService = personService;
   }

   public void generateFopReport(OutputStream out, String personName) {
       // GGG-INCLUDE(PersonPrintFopReport.jsp, out)
   }

}


/src/main/template/PersonPrintFopReport.jsp
===========================================
<%! PersonService personService;%>
<%-- GGG-START --%>

<% Person person = personService.findPerson(personName);%>
<fo:block>
   <%= person.getBirthDate()%>
</fo:block>


Creates a generated source like:

/target/generated-srouces/PersonPrintImpl.java
==============================================


public class PersonPrintImpl implements PersonPrint {

   private PersonService personService;
   public void setPersonService(PersonService personService) {
       this.personService = personService;
   }

   public void generateFopReport(OutputStream out, String personName) {
        Person person = personService.findPerson(personName);
        out.println("<fo:block>");
        out.println(person.getBirthDate());
        out.println("</fo:block>");
   }

}


Of course a better name then GGG should be found for this technology.



Geoffrey De Smet wrote:
Velocity is indeed exactly what I need,
the only problem is that it's yet another language (probably easy to learn, but still). I wonder how hard it would be to create a Jelocity: Velocity with JSP-like syntax.

Christian Geisert wrote:
Geoffrey De Smet schrieb:
I've worked with both FOP and JasperReports
and I really prefer the FO format over jasperreport's custom format.
But Jasperreports allows to use Java/POJO based transformations, so I am wondering if this is possible in FOP.

Basically the idea is to replace:
- generate XML based on POJO
- transform XML with XSL to FO
- feed FOP the FO
with
- supply POJO to "JSP without http" which generates FO
- feed FOP the FO

Does anyone know an (open source?) library which can do something like:
Sounds like a template engine like velocity[1] might be something for you.

Christian

[1] http://jakarta.apache.org/velocity/index.html

--
With kind regards,
Geoffrey De Smet


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to