You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Patrick Casey <pa...@adelphia.net> on 2005/11/04 00:58:13 UTC

Generating Links to Components outside the request cycle

 

            I've got a situation where I'm engaging in a bit of awkward
juditsu to work around what I think is a tapestry limitation and I was
hoping somebody might be able to suggest a better way to do it.

 

            In brief, I have to send out a lot of emails in response to
certain user actions. We're not talking thousands here, but a few hundred
isn't inconceivable. Each of these emails needs to include external links
back to certain tapestry pages within its text.

 

            Since I don't want the user to have to wait (in foreground) for
100 emails to get sent by the server, I just put a request in my background
queue to send the emails and forget about it.

 

            The only hitch is, when the background worker thread gets around
to processing the request, the Tapestry cycle is long gone, which makes it
very hard to generate the URLs I need as my usual URL generation approach:

 

            IEngineService service =
fCycle.getEngine().getService(Tapestry.DIRECT_SERVICE);

                        Object[] parms = new Object[4];

                        parms[0] = fChart.getTargetClass();


                        parms[1] = row;             

                        parms[2] = fChart.getGroup();

                        parms[3] = fChart.getQuery();

                        ILink link = service.getLink(fCycle, fTarget,
parms);

 

            Requires that I have access to the cycle. Even slogging through
the bowels of the engine services code didn't expose a practical way to
avoid this kind of dependency on having access to the cycle.

 

            What I'm doing as a workaround is generating the URL in the
foreground (tapestry page code) and stuffing it into the background task so
that the BG thread sidesteps this issue. 

 

Is there a better solution available? All I really want to do is encode an
external link to a particular page with a particular set of parameters.

 

Thanks,

 

--- Pat


Re: Generating Links to Components outside the request cycle

Posted by Kent Tong <ke...@cpttm.org.mo>.
Patrick Casey <patcasey <at> adelphia.net> writes:

>             In brief, I have to send out a lot of emails in response to
> certain user actions. We're not talking thousands here, but a few hundred
> isn't inconceivable. Each of these emails needs to include external links
> back to certain tapestry pages within its text.

External links have a pre-defined format. So, you can generate the
links yourself using say MessageFormat.

Or you could use the external service itself to generate a prototype
link like http://localhost/foo/app?service=external&page=Bar&sp=SPLACE-HOLDER,
then search "PLACE-HOLDER" and replace your real value for it.

--
Author of a book for learning Tapestry (http://www.agileskills2.org/EWDT)


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org