You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Rob Dennett <ro...@tmit1.org> on 2005/09/19 23:14:54 UTC

inserting links into dynamic content

I have a situation where text from the database needs to be inserted from the database.  I want to be able to parse this text for words that appear in a glossary, and if so, render a link around them that opens a new window containing the definition for the glossary term.  Since you can’t add components at run time, it seems that the only way to do it is to have a component that uses IMarkupWriter to dynamically add an anchor tag around the text with the same href that tapestry would generate if you were using a component.  Is this correct or is there a simpler way to do it?

 

As I finished typing this, I thought of a more Tapestry-like way and I would like to share it.  Split the text into a collection of words.   Then do something like this:

 

<span jwcid=”@For”  value=”word”  source=”words”>

            <span jwcid=”@If” condition=”ognl:inGlossary(word)”>

                        <a href=”#” jwcid=”@PopupLink”><span jwcid=”@Insert” value=”ognl:word”/></a>

                        <span jwcid=”@Else”><span jwcid=”@Insert” value=”ognl:word”/></span>

            </span>

</span>

 

I have left adding in spaces and punctuation marks as an exercise for the reader <span jwcid=”@Grin”/>

 

For what it’s worth,

Rob


-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.11.1/104 - Release Date: 9/16/2005
 

Re: inserting links into dynamic content

Posted by Ron Piterman <rp...@gmx.net>.
Look for a thread called "creating a link around a part of a sentance". 
The last posting contains a solution.


ציטוט Rob Dennett:
> I have a situation where text from the database needs to be inserted from the database.  I want to be able to parse this text for words that appear in a glossary, and if so, render a link around them that opens a new window containing the definition for the glossary term.  Since you can’t add components at run time, it seems that the only way to do it is to have a component that uses IMarkupWriter to dynamically add an anchor tag around the text with the same href that tapestry would generate if you were using a component.  Is this correct or is there a simpler way to do it?
> 
>  
> 
> As I finished typing this, I thought of a more Tapestry-like way and I would like to share it.  Split the text into a collection of words.   Then do something like this:
> 
>  
> 
> <span jwcid=”@For”  value=”word”  source=”words”>
> 
>             <span jwcid=”@If” condition=”ognl:inGlossary(word)”>
> 
>                         <a href=”#” jwcid=”@PopupLink”><span jwcid=”@Insert” value=”ognl:word”/></a>
> 
>                         <span jwcid=”@Else”><span jwcid=”@Insert” value=”ognl:word”/></span>
> 
>             </span>
> 
> </span>
> 
>  
> 
> I have left adding in spaces and punctuation marks as an exercise for the reader <span jwcid=”@Grin”/>
> 
>  
> 
> For what it’s worth,
> 
> Rob
> 
> 


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