I'd recommend the same general approach as Richard - write a "technical" domain service, and inject into domain objects.
On the big NO system over in Ireland, there have been several ways of doing this in the 7 or 8 years that this project has been running. The latest incarnation is to use the OpenXmlDocument APIs, ie the APIs that let you programmatically build or "mail-merge"
into .docx docs.
I designed a little "OpenXmlDocumentService" service that takes in an XML document such as:
The service interprets XML to do a mail merge into relevant fields, with the "type" attribute telling it the strategy to do the mail merge. The result of calling the service is a byte array of the .docx.
One other thing: in order to generate the input XML, you could have the domain object just build up the XML by hand, or you might want to use the NO-provided XmlSnapshot class to generate an XML snapshot of the domain object, and the use an XsltService
to transform that XML into the input as required by the OpenXmlDocumentService.
Hope that makes some sort of sense. As Richard says, this'd make a nice open source contribution; I'd be happy to collaborate if you want.
On 2 March 2012 12:09, PatInABox <email@example.com>
I'm interested in different ways people have gone around generating printable and electronic ie excel, pdf, word etc report type output from Naked Objects applications.
I'm currently building a school management application and need functionality to print items such as class rolls, and fees statements.
I'm at a bit of a loss on how to go about this, I've looked at contributed actions or custom controllers and views, but am wondering if it might not be better to create a system service to an outside application for this reporting, either that or have I
missed some funtionality inside the Naked Objects framework.