You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Cory Watson <jh...@gmail.com> on 2005/09/14 05:54:42 UTC

External Stylesheet (TP4) and Assets

Tapestry 3 had the <external-asset> for linking to a stylesheet that wasn't 
included in the WAR of my web app. I saw some references in TP4 to an 
external loader fo assets, but I can't tickle it in a way that isn't context 
or classpath. I see that I can give it an unrecognized prefix (http: for 
example) and have it pass it through unchanged. What if I just want it 
request /stylesheet.css? I don't want it in my context or classpath.

While I'm at it, the ChartService example that comes with TP4-beta6 seems to 
still be TP3-ified. Can someone clue me in to how to get ChartService 
working in TP4? I see how to set it up in hivemodule.xml, but extending 
AbstractAsset with ChartAsset and instantiating it in the page doesn't seem 
to be the Right Way anymore. I see that services could request the chart 
service via chart.svc from the app, but my service(IRequestCycle) method is 
written to handle:

String pageName = cycle.getParameter(ServiceConstants.PAGE);
String componentId = cycle.getParameter(ServiceConstants.COMPONENT);

IPage page = cycle.getPage();
IComponent component = page.getNestedComponent(componentId);
IChartProvider provider = (IChartProvider) component;

But when I call it as a service, getPage() returns null! This makes complete 
sense to me, I just don't understand how I'm supposed to utilize this new 
service setup. Any help is appreciated ;)

-- 
Cory 'G' Watson
http://www.onemogin.com

Re: External Stylesheet (TP4) and Assets

Posted by Cory Watson <jh...@gmail.com>.
On 9/15/05, Kent Tong <ke...@cpttm.org.mo> wrote:
> 
> Cory Watson <jheephat <at> gmail.com <http://gmail.com>> writes:
> 
> service=chart is telling Tapestry to call the chart service
> (not the page service). page=Bar is telling the chart
> service that the Bar page is a component that implements
> IChartProvider.


Ok, I follow that. Unfortunately, I've broken my app in some other places in 
the name of progress. I'll have to revisit this later. I appreciate the 
help.

No. A service encoder is needed only if we need friendly URL
> such as:
> 
> http://localhost/foo/chart/Bar
> 

Oh, I'll definitely be wanting that. I'll revisit it once I get it work with 
ugly URLs.


-- 
Cory 'G' Watson
http://www.onemogin.com

Re: External Stylesheet (TP4) and Assets

Posted by Kent Tong <ke...@cpttm.org.mo>.
Cory Watson <jheephat <at> gmail.com> writes:

> > Yes. The URL may look like
> > http://localhost/foo/app?service=chart&page=Bar
> 
> Interesting.  I feel we are getting closer!
> 
> How does the 'service=chart' parameter change the behavior of the Bar  
> page?  Does it inject the service or something?

service=chart is telling Tapestry to call the chart service
(not the page service). page=Bar is telling the chart
service that the Bar page is a component that implements
IChartProvider.

> Again, I apologize for being dense ;)  You mentioned a service  
> encoder in the earlier message.  I'm apparently missing something  
> here...

No. A service encoder is needed only if we need friendly URL
such as:

  http://localhost/foo/chart/Bar

--
Author of e-book for learning Tapestry (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


Re: External Stylesheet (TP4) and Assets

Posted by Cory Watson <jh...@gmail.com>.
On Sep 15, 2005, at 10:48 AM, Kent Tong wrote:

> Cory Watson <jheephat <at> gmail.com> writes:
>
>
>> I appreciate the response, and I'm sure that if I was less naive
>> about Tapestry your response would give me some direction.
>> Unfortunately, it doesn't do much for me :(  Can you give me some
>> hints?  Am I expect to make ChartService take parameters just like a
>> page in TP4?
>>
>
> Yes. The URL may look like
> http://localhost/foo/app?service=chart&page=Bar

Interesting.  I feel we are getting closer!

How does the 'service=chart' parameter change the behavior of the Bar  
page?  Does it inject the service or something?

Again, I apologize for being dense ;)  You mentioned a service  
encoder in the earlier message.  I'm apparently missing something  
here...

Cory Watson
http://www.onemogin.com


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


Re: External Stylesheet (TP4) and Assets

Posted by Kent Tong <ke...@cpttm.org.mo>.
Cory Watson <jheephat <at> gmail.com> writes:

> I appreciate the response, and I'm sure that if I was less naive  
> about Tapestry your response would give me some direction.   
> Unfortunately, it doesn't do much for me :(  Can you give me some  
> hints?  Am I expect to make ChartService take parameters just like a  
> page in TP4?

Yes. The URL may look like 
http://localhost/foo/app?service=chart&page=Bar

where the Bar page implements IChartProvider.

--
Author of an e-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


Re: External Stylesheet (TP4) and Assets

Posted by Cory Watson <jh...@gmail.com>.
On Sep 14, 2005, at 11:58 AM, Kent Tong wrote:

> Cory Watson <jheephat <at> gmail.com> writes:
>> Tapestry 3 had the <external-asset> for linking to a stylesheet  
>> that wasn't
>> included in the WAR of my web app. I saw some references in TP4 to an
>  <snip>
> You may try providing an implementation for the service point
> tapestry.asset.LookupAssetFactory. It will be called to create
> an asset when it has no prefix. In your code, you can create
> an ExternalAsset.

That sounds like something I can work with!  Thanks!

>> While I'm at it, the ChartService example that comes with TP4- 
>> beta6 seems to
>> still be TP3-ified. Can someone clue me in to how to get ChartService
>
> You shouldn't use the svc service encoder as it only works for
> services taking no parameters. You should make sure it works
> with ugly URLs first. Only then should you start to create your
> own service encoder.

I appreciate the response, and I'm sure that if I was less naive  
about Tapestry your response would give me some direction.   
Unfortunately, it doesn't do much for me :(  Can you give me some  
hints?  Am I expect to make ChartService take parameters just like a  
page in TP4?

Cory Watson
http://www.onemogin.com


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


Re: External Stylesheet (TP4) and Assets

Posted by Kent Tong <ke...@cpttm.org.mo>.
Cory Watson <jheephat <at> gmail.com> writes:

> 
> Tapestry 3 had the <external-asset> for linking to a stylesheet that wasn't 
> included in the WAR of my web app. I saw some references in TP4 to an 
> external loader fo assets, but I can't tickle it in a way that isn't context 
> or classpath. I see that I can give it an unrecognized prefix (http: for 
> example) and have it pass it through unchanged. What if I just want it 
> request /stylesheet.css? I don't want it in my context or classpath.

You may try providing an implementation for the service point
tapestry.asset.LookupAssetFactory. It will be called to create
an asset when it has no prefix. In your code, you can create
an ExternalAsset.

> While I'm at it, the ChartService example that comes with TP4-beta6 seems to 
> still be TP3-ified. Can someone clue me in to how to get ChartService 
> working in TP4? I see how to set it up in hivemodule.xml, but extending 
> AbstractAsset with ChartAsset and instantiating it in the page doesn't seem 
> to be the Right Way anymore. I see that services could request the chart 
> service via chart.svc from the app, but my service(IRequestCycle) method is 
> written to handle:
> 
> String pageName = cycle.getParameter(ServiceConstants.PAGE);
> String componentId = cycle.getParameter(ServiceConstants.COMPONENT);

You shouldn't use the svc service encoder as it only works for
services taking no parameters. You should make sure it works
with ugly URLs first. Only then should you start to create your
own service encoder.

--
Author of an e-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