You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Allen Guo <el...@gmail.com> on 2007/06/09 17:37:25 UTC

How can I use javascript in html template with TP5.0.4

Hi All,

I use javascript in my html template file like this.
15 	<script>
16 	function pr_single_select(id, reset_all) {
17 	alert("OK");
18 	if (reset_all == true) {
19 	for ( i = 0; i < document.forms.frmProducts.length; i++) {
20 	if (document.forms.frmProducts.elements[i].type == 'checkbox') {
21 	document.forms.frmProducts.elements[i].checked = false;
22 	}
23 	}
24 	}


But I always got exception below.
Failure parsing template context:WEB-INF/shop/ProductList.html: The
content of elements must consist of well-formed character data or markup.

location
    context:WEB-INF/shop/ProductList.html, line 19, column 23 (see above)

....

org.xml.sax.SAXParseException
The content of elements must consist of well-formed character data or
markup.

Why? This is my first use javascript to my html tempplate file. what
should i do ?

Thanks
Allen Guo



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


Re: How can I use javascript in html template with TP5.0.4

Posted by Allen Guo <el...@gmail.com>.
I tried it.But it still don't work.
Even it can work, I think this is also not good.
Becuase it make writting javascript in html template becomes so complex.

I remember in T4, I can add a same .script file with page class then
write javascript in it.
Can I do it like above in T5?



Timo Hillerns 写道:
> hi allen,
> replace your '<' character with '&lt;' in line 19 should fix it.
>
> regards,
> timo
>
> Allen Guo wrote:
>   
>> Hi All,
>>
>> I use javascript in my html template file like this.
>> 15 	<script>
>> 16 	function pr_single_select(id, reset_all) {
>> 17 	alert("OK");
>> 18 	if (reset_all == true) {
>> 19 	for ( i = 0; i < document.forms.frmProducts.length; i++) {
>> 20 	if (document.forms.frmProducts.elements[i].type == 'checkbox') {
>> 21 	document.forms.frmProducts.elements[i].checked = false;
>> 22 	}
>> 23 	}
>> 24 	}
>>
>>
>> But I always got exception below.
>> Failure parsing template context:WEB-INF/shop/ProductList.html: The
>> content of elements must consist of well-formed character data or markup.
>>
>> location
>>     context:WEB-INF/shop/ProductList.html, line 19, column 23 (see above)
>>
>> ....
>>
>> org.xml.sax.SAXParseException
>> The content of elements must consist of well-formed character data or
>> markup.
>>
>> Why? This is my first use javascript to my html tempplate file. what
>> should i do ?
>>
>> Thanks
>> Allen Guo
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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
>
>
>   


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


Re: How can I use javascript in html template with TP5.0.4

Posted by Timo Hillerns <th...@googlemail.com>.
hi allen,
replace your '<' character with '&lt;' in line 19 should fix it.

regards,
timo

Allen Guo wrote:
> Hi All,
>
> I use javascript in my html template file like this.
> 15 	<script>
> 16 	function pr_single_select(id, reset_all) {
> 17 	alert("OK");
> 18 	if (reset_all == true) {
> 19 	for ( i = 0; i < document.forms.frmProducts.length; i++) {
> 20 	if (document.forms.frmProducts.elements[i].type == 'checkbox') {
> 21 	document.forms.frmProducts.elements[i].checked = false;
> 22 	}
> 23 	}
> 24 	}
>
>
> But I always got exception below.
> Failure parsing template context:WEB-INF/shop/ProductList.html: The
> content of elements must consist of well-formed character data or markup.
>
> location
>     context:WEB-INF/shop/ProductList.html, line 19, column 23 (see above)
>
> ....
>
> org.xml.sax.SAXParseException
> The content of elements must consist of well-formed character data or
> markup.
>
> Why? This is my first use javascript to my html tempplate file. what
> should i do ?
>
> Thanks
> Allen Guo
>
>
>
> ---------------------------------------------------------------------
> 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: How can I use javascript in html template with TP5.0.4

Posted by Jiri Mares <Ji...@svt.cz>.
Hi,

why not to use CDATA section:

<script>
<![CDATA[
  function pr_single_select(id, reset_all) {
    alert("OK");
    if (reset_all == true) {
      for ( i = 0; i < document.forms.frmProducts.length; i++) {
        if (document.forms.frmProducts.elements[i].type == 'checkbox') {
          document.forms.frmProducts.elements[i].checked = false;
        }
      }
    }
  }
]]>
</script>

Jirka

Allen Guo napsal(a):
> Hi All,
> 
> I use javascript in my html template file like this.
> 15 	<script>
> 16 	function pr_single_select(id, reset_all) {
> 17 	alert("OK");
> 18 	if (reset_all == true) {
> 19 	for ( i = 0; i < document.forms.frmProducts.length; i++) {
> 20 	if (document.forms.frmProducts.elements[i].type == 'checkbox') {
> 21 	document.forms.frmProducts.elements[i].checked = false;
> 22 	}
> 23 	}
> 24 	}
> 
> 
> But I always got exception below.
> Failure parsing template context:WEB-INF/shop/ProductList.html: The
> content of elements must consist of well-formed character data or markup.
> 
> location
>     context:WEB-INF/shop/ProductList.html, line 19, column 23 (see above)
> 
> ....
> 
> org.xml.sax.SAXParseException
> The content of elements must consist of well-formed character data or
> markup.
> 
> Why? This is my first use javascript to my html tempplate file. what
> should i do ?
> 
> Thanks
> Allen Guo
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org

-- 
Jiří Mareš (mailto:Jiri.Mares@svt.cz)
ČSAD SVT Praha, s.r.o. (http://www.svt.cz)
Czech Republic

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