Thought I would let everyone know that I've made a custom view that uses fop (http://xml.apache.org/fop/) to generate a pdf.
I'm not completely convinced that a view is the approproate choice for this
functionality, though, so I'd like to get some feedback. This is slightly
different than a standard mav view in that its output is inherently
non-transformable (the output is binary pdf data).
A command using this view currently looks like:
<command name="fop">
<view name="SUCCESS" type="fop" path="foptest.jsp"/>
</command>
One nice thing is that path can be any url within this webapp that produces
a valid fo file, so it should be able point to another maverick command and
get its transforms that way (haven't tried this):
<command name="fop" class="someController">
<view name="pdf" type="fop" path="foptest.m"/>
<view name="html">
<transform>
<path value="raw.xsl"/>
<path value="to-html.xsl"/>
</transform>
</view>
</command>
<command name="foptest">
<view name="SUCCESS">
<transform>
<path value="raw.xsl"/>
<path value="to-pdf.xsl"/>
</transform>
</view>
</command>
Its working nicely. I've attached the relevant source files, but the war
file is 4.5mb (needs fop.jar, batik.jar, etc), so I decided I'd just sending
a link to it instead of clogging your inboxes:
http://www.scolamoore.com/opt-fop.war
Anyway, do you think a custom view is the way to go with this or do you
think another type is more appropriate? I thought about using a custom
command and it seems to make more sense in some ways, but I wasn't sure how
to go about it--unlike ViewFactory, CommandFactory is a concrete class, not
an interface.
I think the functionality is nice--easy way to get mav to take the same data
and generate html or a pdf (as in the second example). Using batik, svg view
should be pretty straightforward to create as well. Just not sure if I'm
bending the architecture too much.
--jim
FopViewFactory.java
Description: Binary data
FopView.java
Description: Binary data
