You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Cherry Development <av...@cherrydev.com> on 2004/01/03 00:48:03 UTC

Multiple declared components in a template?

I understand that right now, it is not possible to use a declared 
component more than once inside a template.  I'm wondering if anybody 
who's more experience than I am with Tapestry knows why this limitation 
might be necessary.  The trouble I'm finding is that this limitation is 
blocking my ability to re-use code in the .page templates, which would 
be one of the only advantages of using declared components in a .page 
file rather than implicit ones.

A few examples of where this would be extremely useful:

<html snippet>
<ul>
	<li><a jwcid="DirectLinkToSomePage" parameters="A">Page A</a>
	<li><a jwcid="DirectLinkToSomePage" parameters="F">Page F</a>
	<li><a jwcid="DirectLinkToSomePage" parameters="P">Page P</a>
</ul>
</html snippet>

<component id="DirectLinkToSomePage" type="DirectLink">
	<binding name="listener" expression="[Some complex OGNL expression to 
a listener]"/>
</component>

Another obvious example:

<span jwcid="IfSomeCondition">Print one thing</span>
<span jwcid="IfSomeCondition" invert="yes">Print another thing</span>

<component id="IfSomeCondition" type="Boolean">
	<binding name="condition" expression="[Some OGNL boolean expression]"/>
</component>

That, of course, made a very simple if/else type statement.

As stated in the manual, the framework already generates IDs for 
components that are declared implicitly.  Why not let it generate IDs 
for components that are repeats?  Actually, I was surprised at the fact 
that you can make a component partially implicit (implicit parameters) 
and partially declared (declared id to a component in a .page file) but 
NOT be able to use same declared component more than once.  That 
feature would seem somewhat useless without the ability.

So, is this a future feature that just hasn't made it in, or is there 
an important reason why this shouldn't be part of Tapestry?


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


Re: Multiple declared components in a template?

Posted by Cherry Development <av...@cherrydev.com>.
On Jan 3, 2004, at 5:02 PM, Howard M. Lewis Ship wrote:

> I don't have a problem with the general solution, just with the 
> timing. I'm getting pretty desperate
> to wind down 3.0 and start on 3.1. As soon as I finish with the copy 
> edits for the book, Tapestry
> 3.0 will have my complete attention, and we should get out a last beta 
> or even a first rc very soon.
> 3.0 has been in development for well over a year now, much longer than 
> I had anticipated. It's good
> that it gave Spindle a chance to catch up, but we seem to be getting 
> into an endless series of
> "wouldn't it be nice if" changes.

Well, first off, what's your take on this whole 'ambiguous naming' 
issue?  Do you think it's necessary to enforce the 'original' vs. 
'copy' components?  Do you think a non-ambiguous naming method is 
necessary?  What do you think is easiest to implement?

Secondly, how difficult do you think the change would be for someone 
who hasn't worked much with the Tapestry internals before?  I'd be 
happy to make the changes myself, as long as it's unlikely that I will 
break something.  Are those parts of the internals robust or more 
fragile?


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


Re: Multiple declared components in a template?

Posted by Geoff Longman <gl...@intelligentworks.com>.
----- Original Message ----- 
From: "Erik Hatcher" <er...@ehatchersolutions.com>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Sunday, January 04, 2004 4:50 AM
Subject: Re: Multiple declared components in a template?


> I agree with Howard.... no more new code until after 3.0 is final.  
> Let's ship it!

+1

Geoff

Geoffrey Longman
Intelligent Works Inc.


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


Re: Multiple declared components in a template?

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
I agree with Howard.... no more new code until after 3.0 is final.  
Let's ship it!


On Jan 3, 2004, at 8:02 PM, Howard M. Lewis Ship wrote:
> I don't have a problem with the general solution, just with the 
> timing. I'm getting pretty desperate
> to wind down 3.0 and start on 3.1. As soon as I finish with the copy 
> edits for the book, Tapestry
> 3.0 will have my complete attention, and we should get out a last beta 
> or even a first rc very soon.
> 3.0 has been in development for well over a year now, much longer than 
> I had anticipated. It's good
> that it gave Spindle a chance to catch up, but we seem to be getting 
> into an endless series of
> "wouldn't it be nice if" changes.


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


RE: Multiple declared components in a template?

Posted by "Howard M. Lewis Ship" <hl...@comcast.net>.
I don't have a problem with the general solution, just with the timing. I'm getting pretty desperate
to wind down 3.0 and start on 3.1. As soon as I finish with the copy edits for the book, Tapestry
3.0 will have my complete attention, and we should get out a last beta or even a first rc very soon.
3.0 has been in development for well over a year now, much longer than I had anticipated. It's good
that it gave Spindle a chance to catch up, but we seem to be getting into an endless series of
"wouldn't it be nice if" changes.

--
Howard M. Lewis Ship
Creator, Tapestry: Java Web Components
http://jakarta.apache.org/tapestry
http://jakarta.apache.org/commons/sandbox/hivemind/
http://javatapestry.blogspot.com

> -----Original Message-----
> From: Erik Hatcher [mailto:erik@ehatchersolutions.com] 
> Sent: Saturday, January 03, 2004 7:32 PM
> To: Tapestry users
> Subject: Re: Multiple declared components in a template?
> 
> 
> On Jan 3, 2004, at 5:35 PM, Cherry Development wrote:
> > The purpose of my idea is very simple:  Write fewer declarations.  
> > Yes, this might include copying a 'partial' declaration and 
> making it 
> > complete with implicit references.  But you can do this now!
> 
> 
> > I may not be able to convince you that this feature is 
> useful to YOU, 
> > but it would be useful to me, and I imagine other people as well.
> 
> Just a quick addition of my $0.02.... what is being proposed seems so 
> close to what Tapestry already does that it would fit nicely and make 
> life easier in cases where complex component pieces can be 
> reused.  So, 
> I'm ok with the proposed changes I've seen so far (although not even 
> sure special syntax is needed).
> 
> 	Erik
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 


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


Re: Multiple declared components in a template?

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Jan 3, 2004, at 5:35 PM, Cherry Development wrote:
> The purpose of my idea is very simple:  Write fewer declarations.  
> Yes, this might include copying a 'partial' declaration and making it 
> complete with implicit references.  But you can do this now!


> I may not be able to convince you that this feature is useful to YOU, 
> but it would be useful to me, and I imagine other people as well.

Just a quick addition of my $0.02.... what is being proposed seems so 
close to what Tapestry already does that it would fit nicely and make 
life easier in cases where complex component pieces can be reused.  So, 
I'm ok with the proposed changes I've seen so far (although not even 
sure special syntax is needed).

	Erik


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


Re: Multiple declared components in a template?

Posted by Cherry Development <av...@cherrydev.com>.
On Jan 2, 2004, at 9:29 PM, Harish Krishnaswamy wrote:

> Anonymous implicit components cannot be referenced, so there is no 
> question of ambiguity here.

Are you sure about this?  If anonymous components cannot be referenced, 
why does the framework name them in a consistent manner? ($Component, 
$Component$0, $Component$1, etc...)

The purpose of my idea is very simple:  Write fewer declarations.  Yes, 
this might include copying a 'partial' declaration and making it 
complete with implicit references.  But you can do this now!

Think of it, perhaps in this manner:

Currently, you can, using implicit components, declare a component in 
the template.  These may be named by the framework automatically 
(anonymous), OR they may be named manually using the '@' syntax 
(myinsert@Insert creates a component of type Insert called myinsert).
Currently, you can copy a partial or full component in the .page/.jwc 
file using copy-of.  (I say you can copy a partial component because 
the portions of the original component that are declared implicitly in 
the template are NOT copied!)  These must be explicitly named by the 
developer.
How about another addition to the implicit naming syntax that would 
COPY a declared component, basically just extending the way implicit 
components currently work?  As an example, let's use the '%' character 
for this syntax, since it seems to not yet have a special purpose in 
template syntax.

using my previous example:

<component id="DirectLinkToSomePage" type="DirectLink">
     <binding name="listener" expression="[Some complex OGNL expression 
to a listener]"/>
</component>

<html snippet>
<ul>
     <li><a jwcid="DirectLinkToSomePage" parameters="A">Page A</a>    
<!-- First -->
     <li><a jwcid="%DirectLinkToSomePage" parameters="F">Page F</a>     
<!-- Second -->
     <li><a jwcid="NotAmbiguous%DirectLinkToSomePage" 
parameters="P">Page P</a>     <!-- Third -->
</ul>
</html snippet>

The first DirectLinkToSomePage uses the original declared component.
The second is an anonymous copy of it.  It may be named by the 
framework, for example, as %DirectLinkToSomePage.  A subsequent use 
might name it %DirectLinkToSomePage%0.
The third is a non-anonymous copy of it, named NotAmbiguous.

This seems to fix most of your concerns about this idea.  It is now 
obvious which reference is to the original declared component, and 
which is a copy.  It is also possible to name copies directly, just as 
if you had declared them in the .page/.jwc as a copy-to component.

I may not be able to convince you that this feature is useful to YOU, 
but it would be useful to me, and I imagine other people as well.


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


Re: Multiple declared components in a template?

Posted by Harish Krishnaswamy <hk...@comcast.net>.

Cherry Development wrote:

> 
> On Jan 2, 2004, at 7:55 PM, Harish Krishnaswamy wrote:
> 
>> <html snippet>
>> <ul>
>>     <li><a jwcid="DirectLinkToSomePage" parameters="A">Page A</a>
>>     <li><a jwcid="DirectLinkToSomePage" parameters="F">Page F</a>
>>     <li><a jwcid="DirectLinkToSomePage" parameters="P">Page P</a>
>> </ul>
>> </html snippet>
>>
>> <component id="DirectLinkToSomePage" type="DirectLink">
>>     <binding name="listener" expression="[Some complex OGNL expression 
>> to a listener]"/>
>> </component>
>>
>> Now, let's say we want to refer to your "DirectLinkToSomePage" 
>> component with parameters="F", how would you specifically pick that 
>> one out? The expression components.DirectLinkToSomePage is now ambiguous.
> 
> 
> Yes, it is ambiguous, but no more than what happens if you use implicit 
> declarations, as follows:
> 
> <a jwcid="@DirectLink" listener="ognl:somelistener" parameters="A">
> <a jwcid="@DirectLink" listener="ognl:somelistener" parameters="F">

Anonymous implicit components cannot be referenced, so there is no question of ambiguity here.

> 
> It's not very often that I have had a need to refer to a component in a 
> page by its name (actually never, so far).

It doesn't matter if a test case fails for one condition or several conditions, a failure is a 
failure. In this case, the test case that refers the component by ID will fail.

   The above implicit
> declarations would be named, according to the documentation: $DirectLink 
> and $DirectLink$0.  If it's important that you know the exact names of 
> your components, don't name them ambiguously!  :-)

IMO, this is would be a very confusing feature that has very little payoff and should be avoided.

   I'm suggesting
> something that will make declared components re-usable for people that 
> want to use them multiple times in the same page/supercomponent,

Again, component declarations include placeholder tags. You are suggesting the reuse of a partial 
declaration.

  and
> won't change things who find it important that they know exactly what 
> their components are named (in fact, it's just a small extension to the 
> implicit declarations idea).  Basically, if you're using implicit 
> components mostly, the names of your components aren't obvious at this 
> point anyways.
> 
> Do you agree?

Sincerely, I am not convinced with the idea and I have said my part. Let's see what others have got 
to say.

-Harish

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


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


Re: Multiple declared components in a template?

Posted by Cherry Development <av...@cherrydev.com>.
On Jan 2, 2004, at 7:55 PM, Harish Krishnaswamy wrote:

> <html snippet>
> <ul>
>     <li><a jwcid="DirectLinkToSomePage" parameters="A">Page A</a>
>     <li><a jwcid="DirectLinkToSomePage" parameters="F">Page F</a>
>     <li><a jwcid="DirectLinkToSomePage" parameters="P">Page P</a>
> </ul>
> </html snippet>
>
> <component id="DirectLinkToSomePage" type="DirectLink">
>     <binding name="listener" expression="[Some complex OGNL expression 
> to a listener]"/>
> </component>
>
> Now, let's say we want to refer to your "DirectLinkToSomePage" 
> component with parameters="F", how would you specifically pick that 
> one out? The expression components.DirectLinkToSomePage is now 
> ambiguous.

Yes, it is ambiguous, but no more than what happens if you use implicit 
declarations, as follows:

<a jwcid="@DirectLink" listener="ognl:somelistener" parameters="A">
<a jwcid="@DirectLink" listener="ognl:somelistener" parameters="F">

It's not very often that I have had a need to refer to a component in a 
page by its name (actually never, so far).  The above implicit 
declarations would be named, according to the documentation: 
$DirectLink and $DirectLink$0.  If it's important that you know the 
exact names of your components, don't name them ambiguously!  :-)  I'm 
suggesting something that will make declared components re-usable for 
people that want to use them multiple times in the same 
page/supercomponent, and won't change things who find it important that 
they know exactly what their components are named (in fact, it's just a 
small extension to the implicit declarations idea).  Basically, if 
you're using implicit components mostly, the names of your components 
aren't obvious at this point anyways.

Do you agree?


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


Re: Multiple declared components in a template?

Posted by Harish Krishnaswamy <hk...@comcast.net>.

Cherry Development wrote:

> 
> On Jan 2, 2004, at 5:24 PM, Harish Krishnaswamy wrote:
> 
>> I didn't say that, and certainly that's not what I intended to imply. 
>> I was simply correcting your metophor to align it with Tapestry.
> 
> 
> I see.  Sorry I took that the wrong way.
> 
> If I decided to implement the following behavior, could I get some 
> informal comments on if this would probably be merged with the main 
> branch if I submitted a patch?
> 
> Here's the changed behavior.  Note that I'm currently totally naive to 
> the implementation details of the code this interacts with.:
> 
> 1) Templates with multiple declared components of the same name validate
> 
> 2) If the parser finds multiple declared components of the same name, it 
> makes a new instance of them with the following naming scheme:
>     Assuming the original component was called MultiComponent, the 2nd 
> instance of it would be called MultiComponent$0, the 3rd 
> MultiComponent$1, etc, etc.
> 
> This seems pretty simple to me.  The naming scheme was taken from the 
> way Tapestry current renames implicit components (implicit ones are 
> prefixed with another $, however).  I don't see how this could break 
> compatibility with older templates, since in older templates, this 
> syntax would otherwise be invalid.
> 
> Comments?  Ideas?

A component declaration does not only involve specifying the type, but also involves its 
configuration via parameters. I think this is where the disconnect is. Every placeholder tag in the 
template *is a part* of a component declaration, and each of these declarations actually create a 
new instance of the component. Now, allowing multiple components to have the same name will create 
ambiguity. Let's take your example,

<html snippet>
<ul>
     <li><a jwcid="DirectLinkToSomePage" parameters="A">Page A</a>
     <li><a jwcid="DirectLinkToSomePage" parameters="F">Page F</a>
     <li><a jwcid="DirectLinkToSomePage" parameters="P">Page P</a>
</ul>
</html snippet>

<component id="DirectLinkToSomePage" type="DirectLink">
     <binding name="listener" expression="[Some complex OGNL expression to a listener]"/>
</component>

Now, let's say we want to refer to your "DirectLinkToSomePage" component with parameters="F", how 
would you specifically pick that one out? The expression components.DirectLinkToSomePage is now 
ambiguous.

Hope this clarifies.

-Harish

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


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


Re: Multiple declared components in a template?

Posted by Cherry Development <av...@cherrydev.com>.
On Jan 2, 2004, at 5:24 PM, Harish Krishnaswamy wrote:

> I didn't say that, and certainly that's not what I intended to imply. 
> I was simply correcting your metophor to align it with Tapestry.

I see.  Sorry I took that the wrong way.

If I decided to implement the following behavior, could I get some 
informal comments on if this would probably be merged with the main 
branch if I submitted a patch?

Here's the changed behavior.  Note that I'm currently totally naive to 
the implementation details of the code this interacts with.:

1) Templates with multiple declared components of the same name validate

2) If the parser finds multiple declared components of the same name, 
it makes a new instance of them with the following naming scheme:
	Assuming the original component was called MultiComponent, the 2nd 
instance of it would be called MultiComponent$0, the 3rd 
MultiComponent$1, etc, etc.

This seems pretty simple to me.  The naming scheme was taken from the 
way Tapestry current renames implicit components (implicit ones are 
prefixed with another $, however).  I don't see how this could break 
compatibility with older templates, since in older templates, this 
syntax would otherwise be invalid.

Comments?  Ideas?


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


Re: Multiple declared components in a template?

Posted by Harish Krishnaswamy <hk...@comcast.net>.

Cherry Development wrote:

> 
> On Jan 2, 2004, at 5:11 PM, Harish Krishnaswamy wrote:
> 
>>> This is true, but why is it necessary at all?  It seems like a very 
>>> inelegant approach.  Why not just let the framework do this for you?  
>>> It seems like much less maintenance work on your template files 
>>> whenever you would want to add or remove a copy.  Imagine a 
>>> programming language that required you to re-declare a function as 
>>> being the same as another function each time you wanted to use it.
>>
>>
>> Imagine a programming language that lets you declare multiple 
>> variables with the same name within the same namespace. Component 
>> declarations are similar to variable declarations. Component 
>> definitions are similar to class/function definitions.
> 
> 
> I don't see how this metaphor carries, really.  What programming 
> language requires you to re-declare a variable (component declaration) 
> each time you want to access it inside the same function (component 
> definition).  Are you saying that you find the current implementation 
> with its one-use limitation couldn't stand some improvement?

I didn't say that, and certainly that's not what I intended to imply. I was simply correcting your 
metophor to align it with Tapestry.

-Harish

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


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


Re: Multiple declared components in a template?

Posted by Cherry Development <av...@cherrydev.com>.
On Jan 2, 2004, at 5:11 PM, Harish Krishnaswamy wrote:

>> This is true, but why is it necessary at all?  It seems like a very 
>> inelegant approach.  Why not just let the framework do this for you?  
>> It seems like much less maintenance work on your template files 
>> whenever you would want to add or remove a copy.  Imagine a 
>> programming language that required you to re-declare a function as 
>> being the same as another function each time you wanted to use it.
>
> Imagine a programming language that lets you declare multiple 
> variables with the same name within the same namespace. Component 
> declarations are similar to variable declarations. Component 
> definitions are similar to class/function definitions.

I don't see how this metaphor carries, really.  What programming 
language requires you to re-declare a variable (component declaration) 
each time you want to access it inside the same function (component 
definition).  Are you saying that you find the current implementation 
with its one-use limitation couldn't stand some improvement?


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


Re: Multiple declared components in a template?

Posted by Harish Krishnaswamy <hk...@comcast.net>.

Avi Cherry - Cherry Classics Music wrote:
> 
> On Jan 2, 2004, at 4:01 PM, Simon Raveh wrote:
> 
>> We can still use the same component multiple times in the same 
>> template, you just need to give it a different name.
>> just use the copy of  attribute
>>
>> for example
>>
>> <component id="valueInsert" type="Insert" >
>>        <binding name="value" expression="getValueAt( rowIndex, 
>> columnIndex )" />
>>    </component>
>>
>>    <component id="valueInsert1" copy-of="valueInsert"/>
>>    <component id="valueInsert2" copy-of="valueInsert"/>
>>    <component id="valueInsert3" copy-of="valueInsert"/>
>>    <component id="valueInsert4" copy-of="valueInsert"/>
> 
> 
> This is true, but why is it necessary at all?  It seems like a very 
> inelegant approach.  Why not just let the framework do this for you?  It 
> seems like much less maintenance work on your template files whenever 
> you would want to add or remove a copy.  Imagine a programming language 
> that required you to re-declare a function as being the same as another 
> function each time you wanted to use it.

Imagine a programming language that lets you declare multiple variables with the same name within 
the same namespace. Component declarations are similar to variable declarations. Component 
definitions are similar to class/function definitions.

-Harish

   Aren't components supposed to
> be re-usable chunks of web pages?
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


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


Re: Multiple declared components in a template?

Posted by Avi Cherry - Cherry Classics Music <te...@cherry-classics.com>.
On Jan 2, 2004, at 4:01 PM, Simon Raveh wrote:

> We can still use the same component multiple times in the same 
> template, you just need to give it a different name.
> just use the copy of  attribute
>
> for example
>
> <component id="valueInsert" type="Insert" >
>        <binding name="value" expression="getValueAt( rowIndex, 
> columnIndex )" />
>    </component>
>
>    <component id="valueInsert1" copy-of="valueInsert"/>
>    <component id="valueInsert2" copy-of="valueInsert"/>
>    <component id="valueInsert3" copy-of="valueInsert"/>
>    <component id="valueInsert4" copy-of="valueInsert"/>

This is true, but why is it necessary at all?  It seems like a very 
inelegant approach.  Why not just let the framework do this for you?  
It seems like much less maintenance work on your template files 
whenever you would want to add or remove a copy.  Imagine a programming 
language that required you to re-declare a function as being the same 
as another function each time you wanted to use it.  Aren't components 
supposed to be re-usable chunks of web pages?


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


Re: Multiple declared components in a template?

Posted by Simon Raveh <si...@nominum.com>.
We can still use the same component multiple times in the same template, 
you just need to give it a different name.
just use the copy of  attribute

for example

<component id="valueInsert" type="Insert" >
        <binding name="value" expression="getValueAt( rowIndex, 
columnIndex )" />
    </component>

    <component id="valueInsert1" copy-of="valueInsert"/>
    <component id="valueInsert2" copy-of="valueInsert"/>
    <component id="valueInsert3" copy-of="valueInsert"/>
    <component id="valueInsert4" copy-of="valueInsert"/>


Cherry Development wrote:

> I understand that right now, it is not possible to use a declared 
> component more than once inside a template.  I'm wondering if anybody 
> who's more experience than I am with Tapestry knows why this 
> limitation might be necessary.  The trouble I'm finding is that this 
> limitation is blocking my ability to re-use code in the .page 
> templates, which would be one of the only advantages of using declared 
> components in a .page file rather than implicit ones.
>
> A few examples of where this would be extremely useful:
>
> <html snippet>
> <ul>
>     <li><a jwcid="DirectLinkToSomePage" parameters="A">Page A</a>
>     <li><a jwcid="DirectLinkToSomePage" parameters="F">Page F</a>
>     <li><a jwcid="DirectLinkToSomePage" parameters="P">Page P</a>
> </ul>
> </html snippet>
>
> <component id="DirectLinkToSomePage" type="DirectLink">
>     <binding name="listener" expression="[Some complex OGNL expression 
> to a listener]"/>
> </component>
>
> Another obvious example:
>
> <span jwcid="IfSomeCondition">Print one thing</span>
> <span jwcid="IfSomeCondition" invert="yes">Print another thing</span>
>
> <component id="IfSomeCondition" type="Boolean">
>     <binding name="condition" expression="[Some OGNL boolean 
> expression]"/>
> </component>
>
> That, of course, made a very simple if/else type statement.
>
> As stated in the manual, the framework already generates IDs for 
> components that are declared implicitly.  Why not let it generate IDs 
> for components that are repeats?  Actually, I was surprised at the 
> fact that you can make a component partially implicit (implicit 
> parameters) and partially declared (declared id to a component in a 
> .page file) but NOT be able to use same declared component more than 
> once.  That feature would seem somewhat useless without the ability.
>
> So, is this a future feature that just hasn't made it in, or is there 
> an important reason why this shouldn't be part of Tapestry?
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>

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