The LinkFactory service is completely reliant on the servlet container it is running in. It's really not intended to be used outside of a specific http request.
For your use-case friendly urls sure would make a huge difference. On 7/19/06, Shing Hing Man <[EMAIL PROTECTED]> wrote:
You could trying setting the property webRequest in requestGlobals manually before invoking externalService.getLink(). // The following few lines of code set up the property // webRequest and webResponse in requestGlobals. // HttpServletRequest req =(HttpServletRequest)request; HttpServletResponse resp = (HttpServletResponse)response; RequestGlobals requestGlobals = (RequestGlobals) registry.getService("tapestry.globals.RequestGlobals",RequestGlobals.class ); WebRequest webRequest = new ServletWebRequest(req,resp); WebResponse webResponse = new ServletWebResponse(resp); requestGlobals.store(webRequest,webResponse); Usually, the webRequest (and webResponse) in requestGlobal is set in WebRequestServicerPipelineBridge.java. Here is the route to WebRequestServicerPipelineBridge.java : ApplicationServlet.doService -> WebRequestServicerPipelineBridge.service. Shing --- Valdemaras Repšys <[EMAIL PROTECTED]> wrote: > I managed to get the Registry by overriding the > ApplicationServlet and i'm > able to get the external service. > However, it is not clear, when it is correct to > invoke > externalService.getLink(). If it is invoked just > after > ApplicationServlet.init() it fails with exception: > org.apache.hivemind.ApplicationRuntimeException: > Unable to construct service > tapestry.url.LinkFactory: Error building service > tapestry.url.LinkFactory > Caused by: > org.apache.hivemind.ApplicationRuntimeException: > Unable to read > property contextPath of object <SingletonProxy for > tapestry.Infrastructure( > org.apache.tapestry.services.Infrastructure)>:... > java.lang.reflect.InvocationTargetException... > Caused by: java.lang.NullPointerException: Property > 'webRequest' of > <OuterProxy for tapestry.globals.RequestGlobals( > org.apache.tapestry.services.RequestGlobals)> is > null. > > I can get the link if i invoke getLink later.. when > some page was > initialized. > > Valdemaras Repšys > > On 7/18/06, James Carman > <[EMAIL PROTECTED]> wrote: > > > > If you can get to the HiveMind registry, you can > lookup the > > ExternalService > > and use it. > > > > -----Original Message----- > > From: Valdemaras Repšys [mailto:[EMAIL PROTECTED] > > Sent: Tuesday, July 18, 2006 8:27 AM > > To: Tapestry users > > Subject: Re: external link to a tapestry page > > > > Thanks for the answer, Aleksej. > > > > The problem is, this URL must be generated on a > java thread (or class) > > that > > is not an instance of BasePage and is not a > tapestry page. That means i > > have > > no access to ExternalService, right? > > Also, I can't use @Any component because this url > will be sent as an email > > to the user (as a simple text). > > > > Valdemaras Repšys > > > > On 7/18/06, Aleksej <[EMAIL PROTECTED]> wrote: > > > > > > Valdemaras Repšys wrote: > > > > Hi, > > > > i need my application to send emails with the > link to the specific > > > > tapestry > > > > page. How would i generate a link? > > > > > > > > I tried extending a page with IExternalPage > and using the address: > > > > > http://localhost:8080/BioJazz/app?service=external/HitList > > > > What i get is RuntimeException: No engine > service named > > > > 'external/HitList' > > > > is available. > > > > > > > > Link (as in ExternalService API doc): > > > > > http://localhost:8080/BioJazz/app?service=external&context=HitList > > > > gives a > > > > null pointer exception: > > > > > > > > - > org.apache.hivemind.util.Defense.notNull(Defense.java:41) > > > > - > > > > > org.apache.tapestry.engine.RequestCycle.getPage(RequestCycle.java:242) > > > > > > > > - > org.apache.tapestry.engine.ExternalService.service( > > > > ExternalService.java:144) > > > > - > > > > $IEngineService_10c8121ee8c.service($IEngineService_10c8121ee8c.java) > > > > > > > > > > > > Any hint? > > > > Thanks, > > > > Valdemaras Repšys > > > > > > > Do not form links manually, use > "tapestry.services.External" service ( > > > in your case ). > > > First inject it into your page with something > like: > > > <inject property="externalService" > > > object="service:tapestry.services.External" /> > in your page file. > > > Be sure that you have a externalService property > getter like: > > > public abstract IEngineService > getExternalService(); > > > Then, when you need to generate link, just use > > > > "org.apache.tapestry.engine.ExternalServiceParameter" > > > to generate your page parameters ( name and > Object[] ) and call > > > getExternalService().getLink( your parameter > object ). > > > This will return ILink object and you will be > able to call > > > getAbsoluteURL on it, which will return required > Link as a string. > > > On the page you can probably put it using @Any > component, like: > > > <a jwcid="@Any" href="yourLink">go go go</a> > > > ------------- > > > GL > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: > [EMAIL PROTECTED] > > > For additional commands, e-mail: > [EMAIL PROTECTED] > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: > [EMAIL PROTECTED] > > For additional commands, e-mail: > [EMAIL PROTECTED] > > > > > Home page : http://uk.geocities.com/matmsh/index.html ___________________________________________________________ Try the all-new Yahoo! Mail. "The New Version is radically easier to use" – The Wall Street Journal http://uk.docs.yahoo.com/nowyoucan.html --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- Jesse Kuhnert Tacos/Tapestry, team member/developer Open source based consulting work centered around dojo/tapestry/tacos/hivemind.