You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Randy Simon <rs...@bea.com> on 2007/10/26 03:33:29 UTC

Javascript wrapped in comment block

Hi,

 

I just switched from the RI to myfaces.  I've noticed that all my
javascript blocks get wrapped in HTML-style comments.

 

For example, 

 

<script type="text/javascript">

            var foo = 'bar';

</script>

 

Becomes

<script type="text/javascript">

<!--

            var foo = 'bar';

//-->

</script>

 

Is there anyway to disable this?

 

Thanks,

Randy


Notice:  This email message, together with any attachments, may contain information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated entities,  that may be confidential,  proprietary,  copyrighted  and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it.

Re: Javascript wrapped in comment block

Posted by Simon Kitching <sk...@apache.org>.
There is no switch to control this. Currently the script contents are
always commented out. The two options you list below will not have any
affect on this.

It is probably about time that this behaviour was removed. It is there
to support browsers that are too old to recognise the <script> tag, but
I cannot imagine that anyone is using such a browser any more. Note that
browsers that don't *support* javascript should still *recognise* the
tag and know how to handle it.

For XHTML, the script should be in a CDATA section. For HTML, nothing
special needs to be done as <script> tags have very special rules for
parsing their content.

Regards,
Simon

Andreas Niemeyer schrieb:
> Hi,
>
> I'm facing the same problem: everything within the <script> tags is
> commented out.
>
> What "switch" is to set to get this working? Or needs the javascript
> be loaded from a file?
>
> The web.xml has two keys defined:
>
> <context-param>
>           <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
>           <param-value>true</param-value>
>      </context-param>
>     
>      <context-param>
>           <param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
>       <param-value>true</param-value>
>      </context-param>
>
>
> Many regards,
> Andreas
>
>
>
> Mike Kienenberger schrieb:
>> You can submit a patch to make this a configurable parameter in MyFaces.
>>
>> On 10/26/07, Randy Simon <rs...@bea.com> wrote:
>>> Thanks for your reply.  I understand how the comment blocks work.
>>> However, in my case the HTML is being passed through a filter that is
>>> ignoring the content comment blocks.
>>>
>>> I grabbed the MyFaces source and found where this is being done.  It
>>> will put the JavaScript in comments if the content type of the page is
>>> XHTML.  Since I am using facelets, my content type is XHTML.  In
>>> addition, there does not seem to be a way to disable it.
>>>
>>> I think I can come up with another way to work around this.
>>>
>>> -----Original Message-----
>>> From: David Dyer [mailto:ddyer@artifact-software.com]
>>> Sent: Friday, October 26, 2007 5:05 AM
>>> To: MyFaces Discussion
>>> Subject: Re: Javascript wrapped in comment block
>>>
>>> You don't actually need to get rid of it. The html comment tags inside
>>> the javascript block will only be applied by browsers that don't
>>> understand the <script> tag (eg really old IE or Netscape, text only
>>> browsers etc...). It's actually considered good form to have them in.
>>>
>>> David
>>>
>>> Randy Simon wrote:
>>>> Hi,
>>>>
>>>> I just switched from the RI to myfaces. I've noticed that all my
>>>> javascript blocks get wrapped in HTML-style comments.
>>>>
>>>> For example,
>>>>
>>>> <script type="text/javascript">
>>>>
>>>> var foo = 'bar';
>>>>
>>>> </script>
>>>>
>>>> Becomes
>>>>
>>>> <script type="text/javascript">
>>>>
>>>> <!--
>>>>
>>>> var foo = 'bar';
>>>>
>>>> //-->
>>>>
>>>> </script>
>>>>
>>>> Is there anyway to disable this?
>>>>
>>>> Thanks,
>>>>
>>>> Randy
>>>>
>>>>
>>>> Notice: This email message, together with any attachments, may contain
>>>> information of BEA Systems, Inc., its subsidiaries and affiliated
>>>> entities, that may be confidential, proprietary, copyrighted and/or
>>>> legally privileged, and is intended solely for the use of the
>>>> individual or entity named in this message. If you are not the
>>>> intended recipient, and have received this message in error, please
>>>> immediately return this by email and then delete it.
>>>>
>>> ------------------------------------------------------------------------
>>>
>>>> No virus found in this incoming message.
>>>> Checked by AVG Free Edition.
>>>> Version: 7.5.503 / Virus Database: 269.15.10/1091 - Release Date:
>>> 24/10/2007 2:31 PM
>>>
>>> Notice:  This email message, together with any attachments, may
>>> contain information  of  BEA Systems,  Inc.,  its subsidiaries  and 
>>> affiliated entities,  that may be confidential,  proprietary, 
>>> copyrighted  and/or legally privileged, and is intended solely for
>>> the use of the individual or entity named in this message. If you
>>> are not the intended recipient, and have received this message in
>>> error, please immediately return this by email and then delete it.
>>>
>>
>
>


-- 
-- Emails in "mixed" posting style will be ignored
-- (http://en.wikipedia.org/wiki/Posting_style)


Re: Javascript wrapped in comment block

Posted by Andreas Niemeyer <an...@gutzmann.com>.
Hi,

I'm facing the same problem: everything within the <script> tags is 
commented out.

What "switch" is to set to get this working? Or needs the javascript be 
loaded from a file?

The web.xml has two keys defined:

<context-param>
   		<param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
   		<param-value>true</param-value>
  	</context-param>
	
	 <context-param>
   		<param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
   	<param-value>true</param-value>
  	</context-param>


Many regards,
Andreas



Mike Kienenberger schrieb:
> You can submit a patch to make this a configurable parameter in MyFaces.
> 
> On 10/26/07, Randy Simon <rs...@bea.com> wrote:
>> Thanks for your reply.  I understand how the comment blocks work.
>> However, in my case the HTML is being passed through a filter that is
>> ignoring the content comment blocks.
>>
>> I grabbed the MyFaces source and found where this is being done.  It
>> will put the JavaScript in comments if the content type of the page is
>> XHTML.  Since I am using facelets, my content type is XHTML.  In
>> addition, there does not seem to be a way to disable it.
>>
>> I think I can come up with another way to work around this.
>>
>> -----Original Message-----
>> From: David Dyer [mailto:ddyer@artifact-software.com]
>> Sent: Friday, October 26, 2007 5:05 AM
>> To: MyFaces Discussion
>> Subject: Re: Javascript wrapped in comment block
>>
>> You don't actually need to get rid of it. The html comment tags inside
>> the javascript block will only be applied by browsers that don't
>> understand the <script> tag (eg really old IE or Netscape, text only
>> browsers etc...). It's actually considered good form to have them in.
>>
>> David
>>
>> Randy Simon wrote:
>>> Hi,
>>>
>>> I just switched from the RI to myfaces. I've noticed that all my
>>> javascript blocks get wrapped in HTML-style comments.
>>>
>>> For example,
>>>
>>> <script type="text/javascript">
>>>
>>> var foo = 'bar';
>>>
>>> </script>
>>>
>>> Becomes
>>>
>>> <script type="text/javascript">
>>>
>>> <!--
>>>
>>> var foo = 'bar';
>>>
>>> //-->
>>>
>>> </script>
>>>
>>> Is there anyway to disable this?
>>>
>>> Thanks,
>>>
>>> Randy
>>>
>>>
>>> Notice: This email message, together with any attachments, may contain
>>> information of BEA Systems, Inc., its subsidiaries and affiliated
>>> entities, that may be confidential, proprietary, copyrighted and/or
>>> legally privileged, and is intended solely for the use of the
>>> individual or entity named in this message. If you are not the
>>> intended recipient, and have received this message in error, please
>>> immediately return this by email and then delete it.
>>>
>> ------------------------------------------------------------------------
>>> No virus found in this incoming message.
>>> Checked by AVG Free Edition.
>>> Version: 7.5.503 / Virus Database: 269.15.10/1091 - Release Date:
>> 24/10/2007 2:31 PM
>>
>> Notice:  This email message, together with any attachments, may contain information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated entities,  that may be confidential,  proprietary,  copyrighted  and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it.
>>
> 


Re: Javascript wrapped in comment block

Posted by Mike Kienenberger <mk...@gmail.com>.
You can submit a patch to make this a configurable parameter in MyFaces.

On 10/26/07, Randy Simon <rs...@bea.com> wrote:
> Thanks for your reply.  I understand how the comment blocks work.
> However, in my case the HTML is being passed through a filter that is
> ignoring the content comment blocks.
>
> I grabbed the MyFaces source and found where this is being done.  It
> will put the JavaScript in comments if the content type of the page is
> XHTML.  Since I am using facelets, my content type is XHTML.  In
> addition, there does not seem to be a way to disable it.
>
> I think I can come up with another way to work around this.
>
> -----Original Message-----
> From: David Dyer [mailto:ddyer@artifact-software.com]
> Sent: Friday, October 26, 2007 5:05 AM
> To: MyFaces Discussion
> Subject: Re: Javascript wrapped in comment block
>
> You don't actually need to get rid of it. The html comment tags inside
> the javascript block will only be applied by browsers that don't
> understand the <script> tag (eg really old IE or Netscape, text only
> browsers etc...). It's actually considered good form to have them in.
>
> David
>
> Randy Simon wrote:
> >
> > Hi,
> >
> > I just switched from the RI to myfaces. I've noticed that all my
> > javascript blocks get wrapped in HTML-style comments.
> >
> > For example,
> >
> > <script type="text/javascript">
> >
> > var foo = 'bar';
> >
> > </script>
> >
> > Becomes
> >
> > <script type="text/javascript">
> >
> > <!--
> >
> > var foo = 'bar';
> >
> > //-->
> >
> > </script>
> >
> > Is there anyway to disable this?
> >
> > Thanks,
> >
> > Randy
> >
> >
> > Notice: This email message, together with any attachments, may contain
>
> > information of BEA Systems, Inc., its subsidiaries and affiliated
> > entities, that may be confidential, proprietary, copyrighted and/or
> > legally privileged, and is intended solely for the use of the
> > individual or entity named in this message. If you are not the
> > intended recipient, and have received this message in error, please
> > immediately return this by email and then delete it.
> >
> ------------------------------------------------------------------------
> >
> > No virus found in this incoming message.
> > Checked by AVG Free Edition.
> > Version: 7.5.503 / Virus Database: 269.15.10/1091 - Release Date:
> 24/10/2007 2:31 PM
> >
>
>
> Notice:  This email message, together with any attachments, may contain information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated entities,  that may be confidential,  proprietary,  copyrighted  and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it.
>

RE: Javascript wrapped in comment block

Posted by Randy Simon <rs...@bea.com>.
Thanks for your reply.  I understand how the comment blocks work.
However, in my case the HTML is being passed through a filter that is
ignoring the content comment blocks.

I grabbed the MyFaces source and found where this is being done.  It
will put the JavaScript in comments if the content type of the page is
XHTML.  Since I am using facelets, my content type is XHTML.  In
addition, there does not seem to be a way to disable it.

I think I can come up with another way to work around this.

-----Original Message-----
From: David Dyer [mailto:ddyer@artifact-software.com] 
Sent: Friday, October 26, 2007 5:05 AM
To: MyFaces Discussion
Subject: Re: Javascript wrapped in comment block

You don't actually need to get rid of it. The html comment tags inside 
the javascript block will only be applied by browsers that don't 
understand the <script> tag (eg really old IE or Netscape, text only 
browsers etc...). It's actually considered good form to have them in.

David

Randy Simon wrote:
>
> Hi,
>
> I just switched from the RI to myfaces. I've noticed that all my 
> javascript blocks get wrapped in HTML-style comments.
>
> For example,
>
> <script type="text/javascript">
>
> var foo = 'bar';
>
> </script>
>
> Becomes
>
> <script type="text/javascript">
>
> <!--
>
> var foo = 'bar';
>
> //-->
>
> </script>
>
> Is there anyway to disable this?
>
> Thanks,
>
> Randy
>
>
> Notice: This email message, together with any attachments, may contain

> information of BEA Systems, Inc., its subsidiaries and affiliated 
> entities, that may be confidential, proprietary, copyrighted and/or 
> legally privileged, and is intended solely for the use of the 
> individual or entity named in this message. If you are not the 
> intended recipient, and have received this message in error, please 
> immediately return this by email and then delete it.
>
------------------------------------------------------------------------
>
> No virus found in this incoming message.
> Checked by AVG Free Edition. 
> Version: 7.5.503 / Virus Database: 269.15.10/1091 - Release Date:
24/10/2007 2:31 PM
>   


Notice:  This email message, together with any attachments, may contain information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated entities,  that may be confidential,  proprietary,  copyrighted  and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it.

Re: Javascript wrapped in comment block

Posted by David Dyer <dd...@artifact-software.com>.
You don't actually need to get rid of it. The html comment tags inside 
the javascript block will only be applied by browsers that don't 
understand the <script> tag (eg really old IE or Netscape, text only 
browsers etc...). It's actually considered good form to have them in.

David

Randy Simon wrote:
>
> Hi,
>
> I just switched from the RI to myfaces. I’ve noticed that all my 
> javascript blocks get wrapped in HTML-style comments.
>
> For example,
>
> <script type=”text/javascript”>
>
> var foo = ‘bar’;
>
> </script>
>
> Becomes
>
> <script type=”text/javascript”>
>
> <!--
>
> var foo = ‘bar’;
>
> //-->
>
> </script>
>
> Is there anyway to disable this?
>
> Thanks,
>
> Randy
>
>
> Notice: This email message, together with any attachments, may contain 
> information of BEA Systems, Inc., its subsidiaries and affiliated 
> entities, that may be confidential, proprietary, copyrighted and/or 
> legally privileged, and is intended solely for the use of the 
> individual or entity named in this message. If you are not the 
> intended recipient, and have received this message in error, please 
> immediately return this by email and then delete it.
> ------------------------------------------------------------------------
>
> No virus found in this incoming message.
> Checked by AVG Free Edition. 
> Version: 7.5.503 / Virus Database: 269.15.10/1091 - Release Date: 24/10/2007 2:31 PM
>