'renderElement' option for components

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

'renderElement' option for components

NAEEM MALIK
Something that I find would be very useful for
Tapestry developers is a method for components to
output the element they are defined in. This is useful
because components always throw away the element they
are defined in and this element is often an important
part of the HTML page.

For example if my HTML page contains a component
called "menu" as below:

<div class="menu" style="height: 100px; width: 50px;"
jwcid="menu">

</div>

After rendering, I would want the output to be:

<div class="menu" style="height: 100px; width: 50px;">
link1
link2
etc...
</div>

What I will normally get is just a collection of links
without the outer DIV tag.

The only way I can currently achieve the required
output is if the menu component contained an 'element'
parameter which specified the name of the element to
output (in this case 'div') and by using the render
code below.

writer.begin(element);
renderInformalParameters(writer, cycle);
writer.renderBody(writer, cycle);
writer.end(element);

This 'element parameter' solution is not very elegant
but it seems it is the only way to solve this problem
because instances of components know nothing about the
element they are defined in.

In summary, it would be useful for a component to know
about the element it was defined in (just as it knows
about its informal parameters). Even better would be a
'renderElement' option which tells Tapestry to render
the component within the body of the element it was
defined in rather than replacing the element it was
defined in.

Has anyone else had a similar requirement or feel this
enhancement is useful?

Thanks
Naeem Malik

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: 'renderElement' option for components

Random Tapestry User
Naeem,

Yes, I agree.
I've had the occasion to write at least one component to get around just
such a case.

NAEEM MALIK wrote:

>Something that I find would be very useful for
>Tapestry developers is a method for components to
>output the element they are defined in. This is useful
>because components always throw away the element they
>are defined in and this element is often an important
>part of the HTML page.
>
>For example if my HTML page contains a component
>called "menu" as below:
>
><div class="menu" style="height: 100px; width: 50px;"
>jwcid="menu">
>
></div>
>
>After rendering, I would want the output to be:
>
><div class="menu" style="height: 100px; width: 50px;">
>link1
>link2
>etc...
></div>
>
>What I will normally get is just a collection of links
>without the outer DIV tag.
>
>The only way I can currently achieve the required
>output is if the menu component contained an 'element'
>parameter which specified the name of the element to
>output (in this case 'div') and by using the render
>code below.
>
>writer.begin(element);
>renderInformalParameters(writer, cycle);
>writer.renderBody(writer, cycle);
>writer.end(element);
>
>This 'element parameter' solution is not very elegant
>but it seems it is the only way to solve this problem
>because instances of components know nothing about the
>element they are defined in.
>
>In summary, it would be useful for a component to know
>about the element it was defined in (just as it knows
>about its informal parameters). Even better would be a
>'renderElement' option which tells Tapestry to render
>the component within the body of the element it was
>defined in rather than replacing the element it was
>defined in.
>
>Has anyone else had a similar requirement or feel this
>enhancement is useful?
>
>Thanks
>Naeem Malik
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [hidden email]
>For additional commands, e-mail: [hidden email]
>
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: 'renderElement' option for components

Robert Zeigler
In reply to this post by NAEEM MALIK
Not 100% sure on this, but...
As near as I can tell from the "For" component (from t-deli),
it looks like you could define a "templateTag" parameter
which will be automatically set by the framework.
Take a look at "For.jwc" for more details, but, something like:
<parameter name="templateTag" type="java.lang.String" direction="auto"
default-value="null"/>

Robert

NAEEM MALIK wrote:

> Something that I find would be very useful for
> Tapestry developers is a method for components to
> output the element they are defined in. This is useful
> because components always throw away the element they
> are defined in and this element is often an important
> part of the HTML page.
>
> For example if my HTML page contains a component
> called "menu" as below:
>
> <div class="menu" style="height: 100px; width: 50px;"
> jwcid="menu">
>
> </div>
>
> After rendering, I would want the output to be:
>
> <div class="menu" style="height: 100px; width: 50px;">
> link1
> link2
> etc...
> </div>
>
> What I will normally get is just a collection of links
> without the outer DIV tag.
>
> The only way I can currently achieve the required
> output is if the menu component contained an 'element'
> parameter which specified the name of the element to
> output (in this case 'div') and by using the render
> code below.
>
> writer.begin(element);
> renderInformalParameters(writer, cycle);
> writer.renderBody(writer, cycle);
> writer.end(element);
>
> This 'element parameter' solution is not very elegant
> but it seems it is the only way to solve this problem
> because instances of components know nothing about the
> element they are defined in.
>
> In summary, it would be useful for a component to know
> about the element it was defined in (just as it knows
> about its informal parameters). Even better would be a
> 'renderElement' option which tells Tapestry to render
> the component within the body of the element it was
> defined in rather than replacing the element it was
> defined in.
>
> Has anyone else had a similar requirement or feel this
> enhancement is useful?
>
> Thanks
> Naeem Malik
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: 'renderElement' option for components

NAEEM MALIK
Thanks Robert. You were correct. I've checked the Tapestry source and it
turns out that "templateTag" is a special name when used as a parameter.
The javadoc source for ITemplateSource says that "templateTag" is the:

"Name of the component parameter that will be automatically bound to the
HTML tag that is used to insert the component in the parent template"

Just when I thought something wasn't possible in Tapestry, it turns up
as a hidden feature! It should be trivial now to create a base component
which will render itself in the body of the element it was defined in
rather than replacing the element.

Thanks again,
Naeem

-----Original Message-----
From: Robert Zeigler [mailto:[hidden email]]
Sent: 16 May 2005 14:53
To: Tapestry users
Subject: Re: 'renderElement' option for components

Not 100% sure on this, but...
As near as I can tell from the "For" component (from t-deli),
it looks like you could define a "templateTag" parameter
which will be automatically set by the framework.
Take a look at "For.jwc" for more details, but, something like:
<parameter name="templateTag" type="java.lang.String" direction="auto"
default-value="null"/>

Robert

NAEEM MALIK wrote:

> Something that I find would be very useful for
> Tapestry developers is a method for components to
> output the element they are defined in. This is useful
> because components always throw away the element they
> are defined in and this element is often an important
> part of the HTML page.
>
> For example if my HTML page contains a component
> called "menu" as below:
>
> <div class="menu" style="height: 100px; width: 50px;"
> jwcid="menu">
>
> </div>
>
> After rendering, I would want the output to be:
>
> <div class="menu" style="height: 100px; width: 50px;">
> link1
> link2
> etc...
> </div>
>
> What I will normally get is just a collection of links
> without the outer DIV tag.
>
> The only way I can currently achieve the required
> output is if the menu component contained an 'element'
> parameter which specified the name of the element to
> output (in this case 'div') and by using the render
> code below.
>
> writer.begin(element);
> renderInformalParameters(writer, cycle);
> writer.renderBody(writer, cycle);
> writer.end(element);
>
> This 'element parameter' solution is not very elegant
> but it seems it is the only way to solve this problem
> because instances of components know nothing about the
> element they are defined in.
>
> In summary, it would be useful for a component to know
> about the element it was defined in (just as it knows
> about its informal parameters). Even better would be a
> 'renderElement' option which tells Tapestry to render
> the component within the body of the element it was
> defined in rather than replacing the element it was
> defined in.
>
> Has anyone else had a similar requirement or feel this
> enhancement is useful?
>
> Thanks
> Naeem Malik
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: 'renderElement' option for components

Nick Westgate (Work)
In reply to this post by Robert Zeigler
This is also used in the standard "Any" component.

("element" defaults to "templateTag" ...)
<parameter name="element" type="java.lang.String" direction="in" required="no" default-value="templateTag">
<parameter name="templateTag" type="java.lang.String" direction="auto" required="no" default-value="null">

A quick google shows that Mind Bridge committed the
templateTag change to CVS two years ago! This handy
parameter should be in the docs, but I haven't seen it.

I crossed "Any" with (Glen Stampoultzis's) "ButtonSumbit"
to create a useful mutant son: "AnySubmit". My current
project uses it for easy clickable table cells:
     <td jwcid="myAccountLink">

Cheers,
Nick.


Robert Zeigler wrote:

> Not 100% sure on this, but...
> As near as I can tell from the "For" component (from t-deli),
> it looks like you could define a "templateTag" parameter
> which will be automatically set by the framework.
> Take a look at "For.jwc" for more details, but, something like:
> <parameter name="templateTag" type="java.lang.String" direction="auto"
> default-value="null"/>
>
> Robert
>
> NAEEM MALIK wrote:
>
>>Something that I find would be very useful for
>>Tapestry developers is a method for components to
>>output the element they are defined in. This is useful
>>because components always throw away the element they
>>are defined in and this element is often an important
>>part of the HTML page.
>>
>>For example if my HTML page contains a component
>>called "menu" as below:
>>
>><div class="menu" style="height: 100px; width: 50px;"
>>jwcid="menu">
>>
>></div>
>>
>>After rendering, I would want the output to be:
>>
>><div class="menu" style="height: 100px; width: 50px;">
>>link1
>>link2
>>etc...
>></div>
>>
>>What I will normally get is just a collection of links
>>without the outer DIV tag.
>>
>>The only way I can currently achieve the required
>>output is if the menu component contained an 'element'
>>parameter which specified the name of the element to
>>output (in this case 'div') and by using the render
>>code below.
>>
>>writer.begin(element);
>>renderInformalParameters(writer, cycle);
>>writer.renderBody(writer, cycle);
>>writer.end(element);
>>
>>This 'element parameter' solution is not very elegant
>>but it seems it is the only way to solve this problem
>>because instances of components know nothing about the
>>element they are defined in.
>>
>>In summary, it would be useful for a component to know
>>about the element it was defined in (just as it knows
>>about its informal parameters). Even better would be a
>>'renderElement' option which tells Tapestry to render
>>the component within the body of the element it was
>>defined in rather than replacing the element it was
>>defined in.
>>
>>Has anyone else had a similar requirement or feel this
>>enhancement is useful?
>>
>>Thanks
>>Naeem Malik
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: [hidden email]
>>For additional commands, e-mail: [hidden email]
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: 'renderElement' option for components

Nick Westgate (Work)
In reply to this post by Robert Zeigler
(Repost, as my first try didn't show on the list ...)

This is also used in the standard "Any" component.

("element" defaults to "templateTag" ...)
<parameter name="element" type="java.lang.String" direction="in" required="no" default-value="templateTag">
<parameter name="templateTag" type="java.lang.String" direction="auto" required="no" default-value="null">

A quick google shows that Mind Bridge committed the
templateTag change to CVS two years ago! This handy
parameter should be prominent in the docs, but I
haven't seen it (yet).

I crossed "Any" with (Glen Stampoultzis's) "ButtonSumbit"
to create a mutant son: "AnySubmit". My current project
uses it for easy clickable table cells:
     <td jwcid="myAccountLink">

Cheers,
Nick.


Robert Zeigler wrote:

> Not 100% sure on this, but...
> As near as I can tell from the "For" component (from t-deli),
> it looks like you could define a "templateTag" parameter
> which will be automatically set by the framework.
> Take a look at "For.jwc" for more details, but, something like:
> <parameter name="templateTag" type="java.lang.String" direction="auto"
> default-value="null"/>
>
> Robert
>
> NAEEM MALIK wrote:
>
>>Something that I find would be very useful for
>>Tapestry developers is a method for components to
>>output the element they are defined in. This is useful
>>because components always throw away the element they
>>are defined in and this element is often an important
>>part of the HTML page.
>>
>>For example if my HTML page contains a component
>>called "menu" as below:
>>
>><div class="menu" style="height: 100px; width: 50px;"
>>jwcid="menu">
>>
>></div>
>>
>>After rendering, I would want the output to be:
>>
>><div class="menu" style="height: 100px; width: 50px;">
>>link1
>>link2
>>etc...
>></div>
>>
>>What I will normally get is just a collection of links
>>without the outer DIV tag.
>>
>>The only way I can currently achieve the required
>>output is if the menu component contained an 'element'
>>parameter which specified the name of the element to
>>output (in this case 'div') and by using the render
>>code below.
>>
>>writer.begin(element);
>>renderInformalParameters(writer, cycle);
>>writer.renderBody(writer, cycle);
>>writer.end(element);
>>
>>This 'element parameter' solution is not very elegant
>>but it seems it is the only way to solve this problem
>>because instances of components know nothing about the
>>element they are defined in.
>>
>>In summary, it would be useful for a component to know
>>about the element it was defined in (just as it knows
>>about its informal parameters). Even better would be a
>>'renderElement' option which tells Tapestry to render
>>the component within the body of the element it was
>>defined in rather than replacing the element it was
>>defined in.
>>
>>Has anyone else had a similar requirement or feel this
>>enhancement is useful?
>>
>>Thanks
>>Naeem Malik
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: [hidden email]
>>For additional commands, e-mail: [hidden email]
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]