You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Bogdan Calmac <bc...@gmail.com> on 2007/03/12 23:02:14 UTC

T5 - Context parameters and style sheets links

Consider a UserDetail page that has an URL like
"http://server/context/UserDetail/jdoe". Here I'm using the tapestry
style of passing parameters, as part of the context. The problem here
is that if you have a styleset link to "mystyle.css", it will try to
look for "http"://server/context/userdetail/mystyle.css" which of
course does not exit. The alternative to use the full path to the css,
"/context/mystyle.css" is also bad because you don't want to hardcode
the name of the context.

There are 2 correct solutions to this problem which would be nice to
be part of the framework:

1. Allow context information to (optionally) be passed to a page as
query parameters, so the above URL would be
"http://server/context/UserDetail?userid=jdoe". The relative link to
the stylesheet would be fine now, but I don't know if this fits with
the design of the framework.

2. Create something like an AssetLink component that takes care to
prepend so context, so that:

  <link t:type="AssetLink" href="/mystyle.css" rel="stylesheet"
type="text/css"/>

would generate;

<link href="/context/mystyle.css" rel="stylesheet" type="text/css"/>


I would expect there were others who encountered the same quirk. How
did you address it?

Thank you,
Bogdan Calmac.

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


Re: T5 - Context parameters and style sheets links

Posted by Pablo Ruggia <pr...@gmail.com>.
Will be a Shell component that makes possible to add css as assets ?

On 3/14/07, Todd Orr <to...@gmail.com> wrote:
>
> Realistically, the context is not always known during development.
> Business folk could easily come back after the entire QA cycle and say
> that it needs to be changed for marketing reasons. This would require
> a code change that may force an entire round of QA again. There should
> be some way to refer to resources without hard coding the context.
>
> On 3/12/07, Howard Lewis Ship <hl...@gmail.com> wrote:
> > This is a conscious decision, that you will know early on what the
> > context path will be.
> >
> > The effort to avoid this in T4, using a <base> tag, caused far more
> > problems than it solved.
> >
> > A solution using query parameters is likewise: it makes your site
> > off-limits to any kind of search engine, and it tends to create longer
> > and less "pretty" URLs.
> >
> > On 3/12/07, D&J Gredler <dj...@gmail.com> wrote:
> > > I've never had to operate out of a context other than root, so I've
> just
> > > hardcoded it to "/mystyle.css" or whatever...
> > >
> > >
> > > On 3/12/07, Bogdan Calmac <bc...@gmail.com> wrote:
> > > >
> > > > Consider a UserDetail page that has an URL like
> > > > "http://server/context/UserDetail/jdoe". Here I'm using the tapestry
> > > > style of passing parameters, as part of the context. The problem
> here
> > > > is that if you have a styleset link to "mystyle.css", it will try to
> > > > look for "http"://server/context/userdetail/mystyle.css" which of
> > > > course does not exit. The alternative to use the full path to the
> css,
> > > > "/context/mystyle.css" is also bad because you don't want to
> hardcode
> > > > the name of the context.
> > > >
> > > > There are 2 correct solutions to this problem which would be nice to
> > > > be part of the framework:
> > > >
> > > > 1. Allow context information to (optionally) be passed to a page as
> > > > query parameters, so the above URL would be
> > > > "http://server/context/UserDetail?userid=jdoe". The relative link to
> > > > the stylesheet would be fine now, but I don't know if this fits with
> > > > the design of the framework.
> > > >
> > > > 2. Create something like an AssetLink component that takes care to
> > > > prepend so context, so that:
> > > >
> > > >   <link t:type="AssetLink" href="/mystyle.css" rel="stylesheet"
> > > > type="text/css"/>
> > > >
> > > > would generate;
> > > >
> > > > <link href="/context/mystyle.css" rel="stylesheet" type="text/css"/>
> > > >
> > > >
> > > > I would expect there were others who encountered the same quirk. How
> > > > did you address it?
> > > >
> > > > Thank you,
> > > > Bogdan Calmac.
> > > >
> > > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > For additional commands, e-mail: users-help@tapestry.apache.org
> > > >
> > > >
> > >
> >
> >
> > --
> > Howard M. Lewis Ship
> > TWD Consulting, Inc.
> > Independent J2EE / Open-Source Java Consultant
> > Creator and PMC Chair, Apache Tapestry
> > Creator, Apache HiveMind
> >
> > Professional Tapestry training, mentoring, support
> > and project work.  http://howardlewisship.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: T5 - Context parameters and style sheets links

Posted by Robert Zeigler <ro...@scazdl.org>.
Maybe I'm not fully grasping the problem... what's wrong with using a  
context asset?
Instead of saying <link href="/context/default.css"...>, why not do:
<link t:type="Any" href="prop:stylsheet" />

.java:

@Inject("context:default.css")
private Asset _stylesheet;

//note: tapestry will coerce the stylesheet appropriately into the  
client url string
public Asset getStylesheet() {
   return _stylesheet;
}


Then you just need to know the path relative to the context, without  
needing to know the context...

Robert

On Mar 14, 2007, at 3/143:55 PM , Todd Orr wrote:

> Realistically, the context is not always known during development.
> Business folk could easily come back after the entire QA cycle and say
> that it needs to be changed for marketing reasons. This would require
> a code change that may force an entire round of QA again. There should
> be some way to refer to resources without hard coding the context.
>
> On 3/12/07, Howard Lewis Ship <hl...@gmail.com> wrote:
>> This is a conscious decision, that you will know early on what the
>> context path will be.
>>
>> The effort to avoid this in T4, using a <base> tag, caused far more
>> problems than it solved.
>>
>> A solution using query parameters is likewise: it makes your site
>> off-limits to any kind of search engine, and it tends to create  
>> longer
>> and less "pretty" URLs.
>>
>> On 3/12/07, D&J Gredler <dj...@gmail.com> wrote:
>> > I've never had to operate out of a context other than root, so  
>> I've just
>> > hardcoded it to "/mystyle.css" or whatever...
>> >
>> >
>> > On 3/12/07, Bogdan Calmac <bc...@gmail.com> wrote:
>> > >
>> > > Consider a UserDetail page that has an URL like
>> > > "http://server/context/UserDetail/jdoe". Here I'm using the  
>> tapestry
>> > > style of passing parameters, as part of the context. The  
>> problem here
>> > > is that if you have a styleset link to "mystyle.css", it will  
>> try to
>> > > look for "http"://server/context/userdetail/mystyle.css" which of
>> > > course does not exit. The alternative to use the full path to  
>> the css,
>> > > "/context/mystyle.css" is also bad because you don't want to  
>> hardcode
>> > > the name of the context.
>> > >
>> > > There are 2 correct solutions to this problem which would be  
>> nice to
>> > > be part of the framework:
>> > >
>> > > 1. Allow context information to (optionally) be passed to a  
>> page as
>> > > query parameters, so the above URL would be
>> > > "http://server/context/UserDetail?userid=jdoe". The relative  
>> link to
>> > > the stylesheet would be fine now, but I don't know if this  
>> fits with
>> > > the design of the framework.
>> > >
>> > > 2. Create something like an AssetLink component that takes  
>> care to
>> > > prepend so context, so that:
>> > >
>> > >   <link t:type="AssetLink" href="/mystyle.css" rel="stylesheet"
>> > > type="text/css"/>
>> > >
>> > > would generate;
>> > >
>> > > <link href="/context/mystyle.css" rel="stylesheet" type="text/ 
>> css"/>
>> > >
>> > >
>> > > I would expect there were others who encountered the same  
>> quirk. How
>> > > did you address it?
>> > >
>> > > Thank you,
>> > > Bogdan Calmac.
>> > >
>> > >  
>> ---------------------------------------------------------------------
>> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> > > For additional commands, e-mail: users-help@tapestry.apache.org
>> > >
>> > >
>> >
>>
>>
>> --
>> Howard M. Lewis Ship
>> TWD Consulting, Inc.
>> Independent J2EE / Open-Source Java Consultant
>> Creator and PMC Chair, Apache Tapestry
>> Creator, Apache HiveMind
>>
>> Professional Tapestry training, mentoring, support
>> and project work.  http://howardlewisship.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org


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


Re: T5 - Context parameters and style sheets links

Posted by Todd Orr <to...@gmail.com>.
Realistically, the context is not always known during development.
Business folk could easily come back after the entire QA cycle and say
that it needs to be changed for marketing reasons. This would require
a code change that may force an entire round of QA again. There should
be some way to refer to resources without hard coding the context.

On 3/12/07, Howard Lewis Ship <hl...@gmail.com> wrote:
> This is a conscious decision, that you will know early on what the
> context path will be.
>
> The effort to avoid this in T4, using a <base> tag, caused far more
> problems than it solved.
>
> A solution using query parameters is likewise: it makes your site
> off-limits to any kind of search engine, and it tends to create longer
> and less "pretty" URLs.
>
> On 3/12/07, D&J Gredler <dj...@gmail.com> wrote:
> > I've never had to operate out of a context other than root, so I've just
> > hardcoded it to "/mystyle.css" or whatever...
> >
> >
> > On 3/12/07, Bogdan Calmac <bc...@gmail.com> wrote:
> > >
> > > Consider a UserDetail page that has an URL like
> > > "http://server/context/UserDetail/jdoe". Here I'm using the tapestry
> > > style of passing parameters, as part of the context. The problem here
> > > is that if you have a styleset link to "mystyle.css", it will try to
> > > look for "http"://server/context/userdetail/mystyle.css" which of
> > > course does not exit. The alternative to use the full path to the css,
> > > "/context/mystyle.css" is also bad because you don't want to hardcode
> > > the name of the context.
> > >
> > > There are 2 correct solutions to this problem which would be nice to
> > > be part of the framework:
> > >
> > > 1. Allow context information to (optionally) be passed to a page as
> > > query parameters, so the above URL would be
> > > "http://server/context/UserDetail?userid=jdoe". The relative link to
> > > the stylesheet would be fine now, but I don't know if this fits with
> > > the design of the framework.
> > >
> > > 2. Create something like an AssetLink component that takes care to
> > > prepend so context, so that:
> > >
> > >   <link t:type="AssetLink" href="/mystyle.css" rel="stylesheet"
> > > type="text/css"/>
> > >
> > > would generate;
> > >
> > > <link href="/context/mystyle.css" rel="stylesheet" type="text/css"/>
> > >
> > >
> > > I would expect there were others who encountered the same quirk. How
> > > did you address it?
> > >
> > > Thank you,
> > > Bogdan Calmac.
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> > >
> >
>
>
> --
> Howard M. Lewis Ship
> TWD Consulting, Inc.
> Independent J2EE / Open-Source Java Consultant
> Creator and PMC Chair, Apache Tapestry
> Creator, Apache HiveMind
>
> Professional Tapestry training, mentoring, support
> and project work.  http://howardlewisship.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

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


Re: T5 - Context parameters and style sheets links

Posted by Jiri Mares <Ji...@svt.cz>.
Hi all,

this problem is very nice solved in c:url JSP tag. When the URL is absolute (starting with /) then the context is added
before (request.getContextPath()) otherwise the URL is relative and leaved the same as it was.

I think it shouldn't be problem to create component solving this problem.

Jirka

Howard Lewis Ship napsal(a):
> 
> This is a conscious decision, that you will know early on what the
> context path will be.
> 
> The effort to avoid this in T4, using a <base> tag, caused far more
> problems than it solved.
> 
> A solution using query parameters is likewise: it makes your site
> off-limits to any kind of search engine, and it tends to create longer
> and less "pretty" URLs.
> 
> On 3/12/07, D&J Gredler <dj...@gmail.com> wrote:
>> I've never had to operate out of a context other than root, so I've just
>> hardcoded it to "/mystyle.css" or whatever...
>>
>>
>> On 3/12/07, Bogdan Calmac <bc...@gmail.com> wrote:
>> >
>> > Consider a UserDetail page that has an URL like
>> > "http://server/context/UserDetail/jdoe". Here I'm using the tapestry
>> > style of passing parameters, as part of the context. The problem here
>> > is that if you have a styleset link to "mystyle.css", it will try to
>> > look for "http"://server/context/userdetail/mystyle.css" which of
>> > course does not exit. The alternative to use the full path to the css,
>> > "/context/mystyle.css" is also bad because you don't want to hardcode
>> > the name of the context.
>> >
>> > There are 2 correct solutions to this problem which would be nice to
>> > be part of the framework:
>> >
>> > 1. Allow context information to (optionally) be passed to a page as
>> > query parameters, so the above URL would be
>> > "http://server/context/UserDetail?userid=jdoe". The relative link to
>> > the stylesheet would be fine now, but I don't know if this fits with
>> > the design of the framework.
>> >
>> > 2. Create something like an AssetLink component that takes care to
>> > prepend so context, so that:
>> >
>> >   <link t:type="AssetLink" href="/mystyle.css" rel="stylesheet"
>> > type="text/css"/>
>> >
>> > would generate;
>> >
>> > <link href="/context/mystyle.css" rel="stylesheet" type="text/css"/>
>> >
>> >
>> > I would expect there were others who encountered the same quirk. How
>> > did you address it?
>> >
>> > Thank you,
>> > Bogdan Calmac.
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> > For additional commands, e-mail: users-help@tapestry.apache.org
>> >
>> >
>>
> 
> 

-- 
Jiří Mareš (mailto:Jiri.Mares@svt.cz)
ČSAD SVT Praha, s.r.o. (http://www.svt.cz)
Czech Republic

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


Re: T5 - Context parameters and style sheets links

Posted by Howard Lewis Ship <hl...@gmail.com>.
This is a conscious decision, that you will know early on what the
context path will be.

The effort to avoid this in T4, using a <base> tag, caused far more
problems than it solved.

A solution using query parameters is likewise: it makes your site
off-limits to any kind of search engine, and it tends to create longer
and less "pretty" URLs.

On 3/12/07, D&J Gredler <dj...@gmail.com> wrote:
> I've never had to operate out of a context other than root, so I've just
> hardcoded it to "/mystyle.css" or whatever...
>
>
> On 3/12/07, Bogdan Calmac <bc...@gmail.com> wrote:
> >
> > Consider a UserDetail page that has an URL like
> > "http://server/context/UserDetail/jdoe". Here I'm using the tapestry
> > style of passing parameters, as part of the context. The problem here
> > is that if you have a styleset link to "mystyle.css", it will try to
> > look for "http"://server/context/userdetail/mystyle.css" which of
> > course does not exit. The alternative to use the full path to the css,
> > "/context/mystyle.css" is also bad because you don't want to hardcode
> > the name of the context.
> >
> > There are 2 correct solutions to this problem which would be nice to
> > be part of the framework:
> >
> > 1. Allow context information to (optionally) be passed to a page as
> > query parameters, so the above URL would be
> > "http://server/context/UserDetail?userid=jdoe". The relative link to
> > the stylesheet would be fine now, but I don't know if this fits with
> > the design of the framework.
> >
> > 2. Create something like an AssetLink component that takes care to
> > prepend so context, so that:
> >
> >   <link t:type="AssetLink" href="/mystyle.css" rel="stylesheet"
> > type="text/css"/>
> >
> > would generate;
> >
> > <link href="/context/mystyle.css" rel="stylesheet" type="text/css"/>
> >
> >
> > I would expect there were others who encountered the same quirk. How
> > did you address it?
> >
> > Thank you,
> > Bogdan Calmac.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>


-- 
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

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


Re: T5 - Context parameters and style sheets links

Posted by D&J Gredler <dj...@gmail.com>.
I've never had to operate out of a context other than root, so I've just
hardcoded it to "/mystyle.css" or whatever...


On 3/12/07, Bogdan Calmac <bc...@gmail.com> wrote:
>
> Consider a UserDetail page that has an URL like
> "http://server/context/UserDetail/jdoe". Here I'm using the tapestry
> style of passing parameters, as part of the context. The problem here
> is that if you have a styleset link to "mystyle.css", it will try to
> look for "http"://server/context/userdetail/mystyle.css" which of
> course does not exit. The alternative to use the full path to the css,
> "/context/mystyle.css" is also bad because you don't want to hardcode
> the name of the context.
>
> There are 2 correct solutions to this problem which would be nice to
> be part of the framework:
>
> 1. Allow context information to (optionally) be passed to a page as
> query parameters, so the above URL would be
> "http://server/context/UserDetail?userid=jdoe". The relative link to
> the stylesheet would be fine now, but I don't know if this fits with
> the design of the framework.
>
> 2. Create something like an AssetLink component that takes care to
> prepend so context, so that:
>
>   <link t:type="AssetLink" href="/mystyle.css" rel="stylesheet"
> type="text/css"/>
>
> would generate;
>
> <link href="/context/mystyle.css" rel="stylesheet" type="text/css"/>
>
>
> I would expect there were others who encountered the same quirk. How
> did you address it?
>
> Thank you,
> Bogdan Calmac.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>