You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Todd Orr <to...@gmail.com> on 2007/09/11 20:35:55 UTC

T5 component content

I've been pulling my hair out over this problem. How do simply get the
content of a component?

usage given:

<t:comp>
    <p>Some content</p>
</t:comp>

I have found that it's quite impossible to get the content into a
variable from within the component events.

Any ideas?

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


Re: T5 component content

Posted by Todd Orr <to...@gmail.com>.
I wish I had figured it out. As it stands it looks to be quite
impossible to capture the content of a component. I'm beginning to
think that components are woefully insufficient in anything but
trivial examples. More complicated examples like the beanform, or grid
are vastly more complex than they should be. Even the components I've
built out are unnecessarily complex internally.

This whole new component design is reminding me a lot of JSP tags,
except not as powerful. I hope to see some rule bending by HLS in the
future to accommodate strongly related component groups, nesting, etc.
However, it doesn't seem likely.

Even something that seems to be trivial, getting the runtime clientId
of a nested component, is proving to be tremendously difficult. I
truly hope that these are just beta hiccups.

On 9/26/07, Chris Lewis <ch...@bellsouth.net> wrote:
> Indeed, but its not declarative and it doesn't address style sheets.
> Like I said, I'm not hell-bent on a declarative solution, but I do not
> want to:
>
> 1) @Inject/@Path my css ...
> 2) .. and provide a getter ...
> 3) .. for every page!
>
> On top of that it would be quite nice to know only from the template
> what other resources (css, js, etc) the page requires. As I said I'd
> settle for a class level annotation that could be applied to
> pages/components to express what css/js assets should be included. While
> not declarative, its a simple, consistent, at-a-glance way to declare
> and know what assets a page/component needs.
>
> Carl Pulley wrote:
> > You can also add javascript code into the document head via PageRenderSupport
> > (see Form.java for a concrete example).
> >
> >
> > redijedi wrote:
> >
> >> I'm trying to create a component that will allow me to define blocks
> >> of HTML to insert into the head. I think this would be useful for ad
> >> hoc JS, style declarations, etc. I know that this can be inserted
> >> using other mechanisms like:
> >>
> >> Element head = writer.getDocument().find("html/head");
> >>
> >> and inserting your element manually, but this isn't pretty or
> >> easy/possible for the script or style tag contents.
> >>
> >> I know that an alternative is just to slap it in the page where the
> >> component is rendered, but that's just sloppy.
> >>
> >>
> >
> >
>
>

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


Re: T5 component content

Posted by Chris Lewis <ch...@bellsouth.net>.
Thiago,

I will probably do something like this for now, but in my opinion its 
not a suitable solution. Even with this method I am left with the burden 
of injecting however many stylesheets I need, and then providing getters 
for them. I must do this for every page or component that needs its own 
style sheet, and in my opinion its unnecessary boiler plate. Style 
sheets and script files are important entities for pages as they define 
UI and behavior. They are not like other assets such as images or flash 
movies, which typically have a very specific purpose and are not at all 
required for the make up of a page. On the contrary, style sheets and 
scripts are core foundational elements of a page and in my opinion, the 
framework should provide assurance that such elements exist 
(proactive/fail fast) and also provide a seamless and painless way to 
include them.
T5 is halfway there with Assets, and I love that if my page declares a 
missing asset it falls over. However I do not want to inject 3 
stylesheets and then provide getters (or a getter for a list of them 
all) for each page that needs its own style sheets. Subclassing just for 
this purpose also seems nonsensical.
Is there no one else that feels css/js inclusion deserves a bit more 
attention?

PS Didn't T4 have a Style component? It may have even had a Script 
component. I don't know that components for this purpose is the right 
way to go, but at least it was easy (and terse) to use.

Thiago H. de Paula Figueiredo wrote:
> Em Wed, 26 Sep 2007 13:23:47 -0300, Chris Lewis 
> <ch...@bellsouth.net> escreveu:
>
>> Indeed, but its not declarative and it doesn't address style sheets.
>> Like I said, I'm not hell-bent on a declarative solution, but I do not
>> want to:
>>
>> 1) @Inject/@Path my css ...
>> 2) .. and provide a getter ...
>> 3) .. for every page!
>
> What about creating an Layout component to generate the <link> tags 
> you need? That's what I do in my project. The @Inject's and getters 
> would be declared just once (in the Layout class). Your Layout 
> component would have parameters to allow the addition of more <link> 
> tags. ;)
>
> Thiago
>
> ---------------------------------------------------------------------
> 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 component content

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Wed, 26 Sep 2007 13:23:47 -0300, Chris Lewis  
<ch...@bellsouth.net> escreveu:

> Indeed, but its not declarative and it doesn't address style sheets.
> Like I said, I'm not hell-bent on a declarative solution, but I do not
> want to:
>
> 1) @Inject/@Path my css ...
> 2) .. and provide a getter ...
> 3) .. for every page!

What about creating an Layout component to generate the <link> tags you  
need? That's what I do in my project. The @Inject's and getters would be  
declared just once (in the Layout class). Your Layout component would have  
parameters to allow the addition of more <link> tags. ;)

Thiago

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


Re: T5 component content

Posted by Chris Lewis <ch...@bellsouth.net>.
Indeed, but its not declarative and it doesn't address style sheets. 
Like I said, I'm not hell-bent on a declarative solution, but I do not 
want to:

1) @Inject/@Path my css ...
2) .. and provide a getter ...
3) .. for every page!

On top of that it would be quite nice to know only from the template 
what other resources (css, js, etc) the page requires. As I said I'd 
settle for a class level annotation that could be applied to 
pages/components to express what css/js assets should be included. While 
not declarative, its a simple, consistent, at-a-glance way to declare 
and know what assets a page/component needs.

Carl Pulley wrote:
> You can also add javascript code into the document head via PageRenderSupport
> (see Form.java for a concrete example).
>  
>
> redijedi wrote:
>   
>> I'm trying to create a component that will allow me to define blocks
>> of HTML to insert into the head. I think this would be useful for ad
>> hoc JS, style declarations, etc. I know that this can be inserted
>> using other mechanisms like:
>>
>> Element head = writer.getDocument().find("html/head");
>>
>> and inserting your element manually, but this isn't pretty or
>> easy/possible for the script or style tag contents.
>>
>> I know that an alternative is just to slap it in the page where the
>> component is rendered, but that's just sloppy.
>>
>>     
>
>   


Re: T5 component content

Posted by Carl Pulley <c....@acme-labs.org.uk>.
You can also add javascript code into the document head via PageRenderSupport
(see Form.java for a concrete example).
 

redijedi wrote:
> 
> I'm trying to create a component that will allow me to define blocks
> of HTML to insert into the head. I think this would be useful for ad
> hoc JS, style declarations, etc. I know that this can be inserted
> using other mechanisms like:
> 
> Element head = writer.getDocument().find("html/head");
> 
> and inserting your element manually, but this isn't pretty or
> easy/possible for the script or style tag contents.
> 
> I know that an alternative is just to slap it in the page where the
> component is rendered, but that's just sloppy.
> 

-- 
View this message in context: http://www.nabble.com/T5-component-content-tf4424504.html#a12904176
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: T5 component content

Posted by Chris Lewis <ch...@bellsouth.net>.
Hello Todd,

I'm curious if you've made any progress on this as I too am interested 
in a declarative way to insert JS and CSS. The best thing I've come up 
with is a general component used for inserting elements into the head of 
the document. It could be used like this:

<t:pageresource type="style" src="TODO"/>

It may make sense to have components specifically for CSS and JS. This 
method is ok for me except for one issue - getting the assets into the 
src attribute. I *do not* want to have to create boilerplate accessors 
and inject the needed assets into my page/component classes, just so my 
template can reference them!

I'm sure you've seen this, but T5 uses InjectStandardStylesheetCommand 
to assure that the default style sheet always ends up in the document 
head. I don't think we can use this directly as I don't know that you 
can attach render commands to specific pages.

One idea that occurred to me is to create a service that does some final 
render tinkering, perhaps based on the presence of an annotation (like 
@Style or @Script). Of course this isn't at all declarative, but at 
least one wouldn't have to provide page members/accessors for injecting 
the assets and then accessing them.

Any thoughts?

Todd Orr wrote:
> I'm trying to create a component that will allow me to define blocks
> of HTML to insert into the head. I think this would be useful for ad
> hoc JS, style declarations, etc. I know that this can be inserted
> using other mechanisms like:
>
> Element head = writer.getDocument().find("html/head");
>
> and inserting your element manually, but this isn't pretty or
> easy/possible for the script or style tag contents.
>
> I know that an alternative is just to slap it in the page where the
> component is rendered, but that's just sloppy.
>
> On 9/11/07, Howard Lewis Ship <hl...@gmail.com> wrote:
>   
>> It's somewhat impossible.  The content isn't stored as a string, but as a
>> large collection of objects representing different parts of the template as
>> well as components.  You're better off explaining what you want to do if you
>> want to avoid a blind alley.
>>
>> It's a bit easier to get the renderered HTML after a component has rendered.
>>
>> On 9/11/07, Todd Orr <to...@gmail.com> wrote:
>>     
>>> I've been pulling my hair out over this problem. How do simply get the
>>> content of a component?
>>>
>>> usage given:
>>>
>>> <t:comp>
>>>     <p>Some content</p>
>>> </t:comp>
>>>
>>> I have found that it's quite impossible to get the content into a
>>> variable from within the component events.
>>>
>>> Any ideas?
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>>       
>> --
>> Howard M. Lewis Ship
>> Partner and Senior Architect at Feature50
>>
>> Creator Apache Tapestry and Apache HiveMind
>>
>>     
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
>   


Re: T5 component content

Posted by Todd Orr <to...@gmail.com>.
I'm trying to create a component that will allow me to define blocks
of HTML to insert into the head. I think this would be useful for ad
hoc JS, style declarations, etc. I know that this can be inserted
using other mechanisms like:

Element head = writer.getDocument().find("html/head");

and inserting your element manually, but this isn't pretty or
easy/possible for the script or style tag contents.

I know that an alternative is just to slap it in the page where the
component is rendered, but that's just sloppy.

On 9/11/07, Howard Lewis Ship <hl...@gmail.com> wrote:
> It's somewhat impossible.  The content isn't stored as a string, but as a
> large collection of objects representing different parts of the template as
> well as components.  You're better off explaining what you want to do if you
> want to avoid a blind alley.
>
> It's a bit easier to get the renderered HTML after a component has rendered.
>
> On 9/11/07, Todd Orr <to...@gmail.com> wrote:
> >
> > I've been pulling my hair out over this problem. How do simply get the
> > content of a component?
> >
> > usage given:
> >
> > <t:comp>
> >     <p>Some content</p>
> > </t:comp>
> >
> > I have found that it's quite impossible to get the content into a
> > variable from within the component events.
> >
> > Any ideas?
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>
> --
> Howard M. Lewis Ship
> Partner and Senior Architect at Feature50
>
> Creator Apache Tapestry and Apache HiveMind
>

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


Re: T5 component content

Posted by Howard Lewis Ship <hl...@gmail.com>.
It's somewhat impossible.  The content isn't stored as a string, but as a
large collection of objects representing different parts of the template as
well as components.  You're better off explaining what you want to do if you
want to avoid a blind alley.

It's a bit easier to get the renderered HTML after a component has rendered.

On 9/11/07, Todd Orr <to...@gmail.com> wrote:
>
> I've been pulling my hair out over this problem. How do simply get the
> content of a component?
>
> usage given:
>
> <t:comp>
>     <p>Some content</p>
> </t:comp>
>
> I have found that it's quite impossible to get the content into a
> variable from within the component events.
>
> Any ideas?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Howard M. Lewis Ship
Partner and Senior Architect at Feature50

Creator Apache Tapestry and Apache HiveMind

Re: T5 component content

Posted by Josh Canfield <jo...@thedailytube.com>.
What do you want to do with it?

If you want to render it somewhere in the component then use a block
parameter.
<t:comp>
  <t:parameter name="content">
    <p>Some Content</p>
  </t:parameter>
</t:comp>

there are fuller examples in the list.

If you actually want to put into a String, then I don't know. Maybe tell us
your use case and we can figure something out.

Josh


On 9/11/07, Todd Orr <to...@gmail.com> wrote:
>
> I've been pulling my hair out over this problem. How do simply get the
> content of a component?
>
> usage given:
>
> <t:comp>
>    <p>Some content</p>
> </t:comp>
>
> I have found that it's quite impossible to get the content into a
> variable from within the component events.
>
> Any ideas?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.