Re: external link to a tapestry page
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 tapestry.Infrastructure( > org.apache.tapestry.services.Infrastructure)>:... > java.lang.reflect.InvocationTargetException... > Caused by: java.lang.NullPointerException: Property > 'webRequest' of > 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 ). > > >
Re: external link to a tapestry page
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 Repys <[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 tapestry.Infrastructure( > org.apache.tapestry.services.Infrastructure)>:... > java.lang.reflect.InvocationTargetException... > Caused by: java.lang.NullPointerException: Property > 'webRequest' of > org.apache.tapestry.services.RequestGlobals)> is > null. > > I can get the link if i invoke getLink later.. when > some page was > initialized. > > Valdemaras Repys > > 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 Repys [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 Repys > > > > On 7/18/06, Aleksej <[EMAIL PROTECTED]> wrote: > > > > > > Valdemaras Repys 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 Repys > > > > > > > Do not form links manually, use > "tapestry.services.External" service ( > > > in your case ). > > > First inject it into your page with something > like: > > > > > object="service:tapestry.services.External" /> > in your page file. > > > Be sure that you have a externalService property > getter like: > > > public abstract IEngineService > getExternalService(); > > > Then,
Re: external link to a tapestry page
I can access the hivemind registry, i'm sending emails from the same application where the page is (a separate thread). I accessed the externalService on a mailsender thread, thou sometimes i get exceptions when invoking externalService.getLink: tapestry.url.LinkFactory: Error building service tapestry.url.LinkFactory.. Caused by: java.lang.NullPointerException : Property 'webRequest' of is null. Valdemaras Repšys On 7/19/06, Aleksej <[EMAIL PROTECTED]> wrote: Maybe I didn't understand something. You want to send email from the same webapp or from totally different application? In other words, can you access and work Hivemind registry of webapp where your targeted page is? Valdemaras Repšys wrote: > 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: >> > 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: >> go go go >> - >> 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]
Re: external link to a tapestry page
Maybe I didn't understand something. You want to send email from the same webapp or from totally different application? In other words, can you access and work Hivemind registry of webapp where your targeted page is? Valdemaras Repšys wrote: 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: 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: go go go - 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]
Re: external link to a tapestry page
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 :... java.lang.reflect.InvocationTargetException... Caused by: java.lang.NullPointerException: Property 'webRequest' of 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: > 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: > go go go > - > 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]
RE: external link to a tapestry page
You're on the right track by using an External link. Make sure your page implements IExternalPage. We do something similar with one page that we wanted to be "bookmarkable" and the URL Format is quite similar to what you're trying. You'll still have to workaround problems of interdependency between apps if the URL format changes on a different version of Tapestry, and this doesn't account for authentication/security measures, but it's a start. -Original Message- From: Valdemaras Repšys [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 18, 2006 5: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: > 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: > go go go > - > 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]
RE: external link to a tapestry page
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: > 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: > go go go > - > 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]
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: 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: go go go - GL - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: external link to a tapestry page
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: 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: go go go - GL - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]