You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Anton Mezerny <an...@gmail.com> on 2011/04/09 00:40:10 UTC

How to inject string to javascript in template

Hi,

I need to implement component based on javascript library. To make this
component reusable I have to inject some string values inside the <script>
tag in the component template (like some JSON object or html element id).
I have tried with expressions, like ${jsonPropertyValue} and it works, but
there are some errors in template in my IDE (I'm using IDEA).
Is there a better way to inject values from component properties inside the
script tag?

Thanks in advance.
Anton

Re: How to inject string to javascript in template

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Fri, 08 Apr 2011 19:40:10 -0300, Anton Mezerny  
<an...@gmail.com> wrote:

> Hi,

Hi!

> I need to implement component based on javascript library. To make this
> component reusable I have to inject some string values inside the  
> <script> tag in the component template (like some JSON object or html  
> element id).
> I have tried with expressions, like ${jsonPropertyValue} and it works,  
> but there are some errors in template in my IDE (I'm using IDEA).

Which errors?

> Is there a better way to inject values from component properties inside  
> the script tag?

@Inject JavaScriptSupport and use its addScript() method. Anything you'll  
pass to it will be added as is in a <script> element at the bottom of the  
page.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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