You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Olve Hansen <ol...@intermedia.uib.no> on 2005/06/16 10:16:19 UTC
Custom components/services, urls, and session ids
I am currently making a component for handling images streamed from a
database using a custom service and a custom component.
The version of Tapestry is 3.0.3
This component tries to make a context-asset from the link given from
the service, but fails:
ILink resourceLink = resourceService.getLink(
requestCycle, this, new Object[]{param});
setImageIconAsset(new ContextAsset(
new ContextResourceLocation(
requestCycle.getRequestContext().getServlet().getServletContext(),
resourceLink.getURL()
),null /*no ILocation since this is a dynamically added asset*/
));
The resourceService is the custom service, and the link it makes (using
AbstractService.constructLink) includes the context
(e.g. /*context*/app) which is also added when I make the context asset.
So the link the asset gives me become:
/context/context/app?service=resource&sp=ServiceParam
The setImageIconAsset is a method used by the Image component for
displaying the icon for this particular ServiceLink.
Anyone seen this problem before? It would be convenient to be able to
extract the context relative link from ILink, or tell the
ContextResourceLocation that the context is already added to the link.
Now for the next question.
None of the links generated by this approach produces any session id's
if I turn of cookies. This is true for Image component using a
contextAsset, and for the ServiceLink component.
Is this the responsibility of the service implementation? I never see
the url as a String, I am just depending on
AbstractService.constructLink to do the dirty work.
Is there any better approach than this:
String url = resourceLink.getURL();
url = requestCycle.getRequestContext().getResponse().encodeURL(url);
resourceLink = new StaticLink(url);
I also noticed that the TapestryInspector also suffers from lack of
jsessionid in cookie.
Hope someone can help me with this!
Btw, Tapestry Rocks :-)
Regards,
Olve S. Hansen
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Custom components/services, urls, and session ids
Posted by Olve Hansen <ol...@intermedia.uib.no>.
An update:
I see now from the Tapestry source that the EngineServiceLink (made from
constructLink in AbstractService) only encodes the url if the service
calls constructLink with the stateful flag set.
I misinterpreted this as the Service/Page being stateful, and that
something would be put in the visit object.
Guess I was wrong.
For the first problem described in the previous post, I still have to do
the following to get the url right;
ILink resourceLink = resourceService.getLink(requestCycle, this, new
Object[]{param});
String contextName = requestCycle.getEngine().getContextPath();
String url = resourceLink.getURL();
url = url.substring( url.lastIndexOf(contextName)+contextName.length());
url = requestCycle.encodeURL(url);
setImageIconAsset(new ContextAsset(
new ContextResourceLocation(
requestCycle.getRequestContext().getServlet().getServletContext(),
url
),null /*no ILocation since this is a dynamic added asset*/
));
Although it was possible doing this in a bit less wordier fashion than
in my last post, it is still cumbersome.
Does anyone have any tips to do this in a more "correct" way?
And hope my newbism isn't too painful to you all.
Regards,
Olve Hansen
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Custom components/services, urls, and session ids
Posted by Olve Hansen <ol...@intermedia.uib.no>.
An update:
I see now from the Tapestry source that the EngineServiceLink (made from
constructLink in AbstractService) only encodes the url if the service
calls constructLink with the stateful flag set.
I misinterpreted this as the Service/Page being stateful, and that
something would be put in the visit object.
Guess I was wrong.
For the first problem described in the previous post, I still have to do
the following to get the url right;
ILink resourceLink = resourceService.getLink(requestCycle, this, new
Object[]{param});
String contextName = requestCycle.getEngine().getContextPath();
String url = resourceLink.getURL();
url = url.substring( url.lastIndexOf(contextName)+contextName.length());
url = requestCycle.encodeURL(url);
setImageIconAsset(new ContextAsset(
new ContextResourceLocation(
requestCycle.getRequestContext().getServlet().getServletContext(),
url
),null /*no ILocation since this is a dynamic added asset*/
));
Although it was possible doing this in a bit less wordier fashion than
in my last post, it is still cumbersome.
Does anyone have any tips to do this in a more "correct" way?
And hope my newbism isn't too painful to you all.
Regards,
Olve Hansen
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org