You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Janko Muzykant <um...@googlemail.com> on 2007/07/02 11:58:57 UTC

T5 optional css for component

hi all,
i would like to have an optional css for each of my components. optional,
because depending on component's parameter i would like/wouldn't like to
include its css link. Lets imagine edit box with calendar for example -
depending on parameter provided in template file, calendar's css file should
or shouldn't be included in generated page.

How may achieve something like this using T5?

regards,
m.

Re: T5 optional css for component

Posted by Kristian Marinkovic <kr...@porsche.co.at>.
you can add additional HTML nodes to your document whenever you 
want. all you need is the MarkupWriter:

Element e = writer.getDocument().getRootElement().find("head");
e.element("link",....) // adds new element

you could also contribute a css helper class that implements 
PageRenderCommand
to the contributePageRenderInitializer service. any component could then 
reference
this object through

@Enviromental
CSSHelper css;

...
css.addCss("....");

when the cleanup method is invoked you could use the first code snippet to 
generate
a link node for every contributed css file. 

g,
kris





"Janko Muzykant" <um...@googlemail.com> 
02.07.2007 14:41
Bitte antworten an
"Tapestry users" <us...@tapestry.apache.org>


An
"Tapestry users" <us...@tapestry.apache.org>
Kopie

Thema
Re: T5 optional css for component






hi Marcus,
this solution is perfect provided i have a <html><head>....</head></html>
template defined separately for each page. but usually this is written 
once
in some "Border" or "Layout" component's template. In such a case I cannot
predict how many css links will be placed inside <head> section because 
many
pages will use the same layout component.

I would need something like this:

(Layout.html)

<head>
   <t:loop source="cssCollection" value="css">
      <link href="${css}" rel="stylesheet" type="text/css"/>
   </t:loop>
</head>

(Layout.java)

class Layout {
  private List<String> cssCollection;
  ...
}

but the question is: how to fill up the cssCollection array with css links
of all components of given page before the page starts rendering?

On 7/2/07, Marcus <mv...@gmail.com> wrote:
>
> Hi Janko,
>
> You could try:
>
> @Inject
> @Path("context:assets/css/layout.css")
> private Asset _layoutCss;
>
> public Asset getLayoutCss() {
>    if (yourCondition)
>       return _layoutCss;
>    else
>       return "";
> }
>
>
> <head>
>    <link href="${layoutCss}" rel="stylesheet" type="text/css"/>
> </head>
>
>
> Marcus
>


Re: T5 optional css for component

Posted by Janko Muzykant <um...@googlemail.com>.
hi Marcus,
this solution is perfect provided i have a <html><head>....</head></html>
template defined separately for each page. but usually this is written once
in some "Border" or "Layout" component's template. In such a case I cannot
predict how many css links will be placed inside <head> section because many
pages will use the same layout component.

I would need something like this:

(Layout.html)

<head>
   <t:loop source="cssCollection" value="css">
      <link href="${css}" rel="stylesheet" type="text/css"/>
   </t:loop>
</head>

(Layout.java)

class Layout {
  private List<String> cssCollection;
  ...
}

but the question is: how to fill up the cssCollection array with css links
of all components of given page before the page starts rendering?

On 7/2/07, Marcus <mv...@gmail.com> wrote:
>
> Hi Janko,
>
> You could try:
>
> @Inject
> @Path("context:assets/css/layout.css")
> private Asset _layoutCss;
>
> public Asset getLayoutCss() {
>    if (yourCondition)
>       return _layoutCss;
>    else
>       return "";
> }
>
>
> <head>
>    <link href="${layoutCss}" rel="stylesheet" type="text/css"/>
> </head>
>
>
> Marcus
>

Re: T5 optional css for component

Posted by Marcus <mv...@gmail.com>.
Hi Janko,

You could try:

@Inject
@Path("context:assets/css/layout.css")
private Asset _layoutCss;

public Asset getLayoutCss() {
   if (yourCondition)
      return _layoutCss;
   else
      return "";
}


<head>
   <link href="${layoutCss}" rel="stylesheet" type="text/css"/>
</head>


Marcus

Re: T5 optional css for component

Posted by Janko Muzykant <um...@googlemail.com>.
hi Erik,
thank you for your answer, but it seems not to be so easy. all style links
should be placed in the <head> section and if i try to use following:

<t:if test="includeCalendar">
  <*link* rel="stylesheet" href="arkusz.*css* " type="text/*css*" />
</t:if>

css link will be printed out exactly in place where component is used on the
page, not inside <head>....</head>


On 7/2/07, Erik Vullings <er...@gmail.com> wrote:
>
> Hi Janko,
>
> In your html template, you could use:
>     <t:if test="includeCalendar">
>         Include css file
>     <t:parameter name="else">
>         do something else
>     </t:parameter>
>     </t:if>
>
> Cheers
> Erik
>
> On 7/2/07, Janko Muzykant <um...@googlemail.com> wrote:
> >
> > hi all,
> > i would like to have an optional css for each of my components.
> optional,
> > because depending on component's parameter i would like/wouldn't like to
> > include its css link. Lets imagine edit box with calendar for example -
> > depending on parameter provided in template file, calendar's css file
> > should
> > or shouldn't be included in generated page.
> >
> > How may achieve something like this using T5?
> >
> > regards,
> > m.
> >
>

tapestry.InfrastructureOverrides example?

Posted by mu...@fantasymail.de.
Has anyone got an example of how to use the tapestry.InfrastructureOverrides hook? 

I would like to overwrite the Locale and in order to do so also inject the tapestry.globals.WebContext to such a service (and then overwrite the Locale depending on the WebContext).


Thanks!

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


Re: T5 optional css for component

Posted by Erik Vullings <er...@gmail.com>.
Hi Janko,

In your html template, you could use:
    <t:if test="includeCalendar">
        Include css file
    <t:parameter name="else">
        do something else
    </t:parameter>
    </t:if>

Cheers
Erik

On 7/2/07, Janko Muzykant <um...@googlemail.com> wrote:
>
> hi all,
> i would like to have an optional css for each of my components. optional,
> because depending on component's parameter i would like/wouldn't like to
> include its css link. Lets imagine edit box with calendar for example -
> depending on parameter provided in template file, calendar's css file
> should
> or shouldn't be included in generated page.
>
> How may achieve something like this using T5?
>
> regards,
> m.
>