----- Original Message ----- From: "Kent Tong" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Monday, August 29, 2005 12:07 PM
Subject: Re: The hardest problem ever


Vjeran Marcinko <vjeran.marcinko <at> email.t-com.hr> writes:

From: "Kent Tong" <kent <at> cpttm.org.mo>
> Your PdfLink component should take a parameter and pass it to
> your service, which will in turn pass to the PdfHandler. This
> will work even in a loop.

Meaning, anyone who is making such general purpose service/component should
take care to provide way to pass arbitrary number of parameters (such as
DirectLink offers) in some XServiceLink, and offer IRequestCycle argument
inside XServiceProvider interface, so one could fetch parameters by
cycle.getListenerParameters() in it because providing can be dependant upon
various app-specific parameters ?

No. If your XXXServiceProvider should take a Foo object as a parameter,
then your XXXService and XXXServiecLink should both take a Foo object
as a parameter.

That's impossible in cases where I have to specifically call callback/provider interface, and pass it as such to XXXLink component. For example, I use iText library for PDF generation, and for performance reasons, this library doesn't work with some "prepared" PDF content argument for generation, but offers some Document instance to you , which is actually wrapped, and already opened OutputStream, thus writing to OutputStream happens in same time when one fills specify it's content, for cases when working with large documents.

So, my provider interface looks like:
public interface ITextPdfHandler {
   public void writePdfContent(Document document);
}

and page that implements it :
public abstract class PdfTestPage extends MyBasePage implements ITextPdfHandler {
   public abstract long getPresidentId();

   public ITextPdfHandler getPdfHandler() {
       return this;
   }

   public void writePdfContent(Document document) {
       long presidentId = getPresidentId();
       President president = getPresidentDao().getPresident(presidentId);
       document.add(new Paragraph("You vote for: " + president + "!"));
   }
}

So, problem is that in subsequent request, this "presidentId" isn't available anymore. I cannot prepare this Document instance before, and pass it as parameter to XXXLink component (and XXXService). This Document instance is "opened" during XXXService request processing , and passed to handler (page) as such for filling.

If I had something like :
public interface ITextPdfHandler {
   public void writePdfContent(IRequestCycle cycle, Document document);
}
then I would be able to fetch presidentId from cycle, that was passed beforehand through PdfLink component, right?

-Vjeran


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

Reply via email to