You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org> on 2016/02/15 23:57:18 UTC

[jira] [Comment Edited] (MYFACES-3959) Outcommented f:metadata will be also executed

    [ https://issues.apache.org/jira/browse/MYFACES-3959?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15147861#comment-15147861 ] 

Leonardo Uribe edited comment on MYFACES-3959 at 2/15/16 10:56 PM:
-------------------------------------------------------------------

I have checked the compiler step-by-step and the tag is never compiled or executed. But any EL expression inside a comment is compiled and evaluated, so it gives the impression that the listener is being called by the tag, but in fact the renderer is calling the code.

The reason why EL expressions are evaluated inside comment blocks is in some cases <script> tags surround the inner code with a comment block. It is not possible to disable this behavior, since it has a valid use case and has worked in that way for a long time.

The suggested way to do it is surround the block with a <ui:remove> tag, which excludes the block from the compilation step.

But I notice that with f:metadata this doesn't work:

{code:java}
<ui:remove>
    <!-- Should not be here after compile -->
<f:metadata>
<f:viewAction actionListener="#
{forwardDispatcherBean.manageActionListener()}

" />
</f:metadata>
</ui:remove>
{code}

The reason is f:metadata is an special tag. In MyFaces there is a SAX handler that detect this tag and exclude everything before/after this tag, but ui:remove is also an special tag, but works only after the whole file has been parsed and the AST tree is built, so if a f:metadata is inside ui:remove, the instance of ui:remove is ignored.

I'll fix it for 2.2.x branch.


was (Author: lu4242):
I have checked the compiler step-by-step and the tag is never compiled or executed. But any EL expression inside a comment is compiled and evaluated, so it gives the impression that the listener is being called by the tag, but in fact the renderer is calling the code.

The reason why EL expressions are evaluated inside comment blocks is in some cases <script> tags surround the inner code with a comment block. It is not possible to disable this behavior, since it has a valid use case and has worked in that way for a long time.

The suggested way to do it is surround the block with a <ui:remove> tag, which excludes the block from the compilation step.

But I notice that with f:metadata this doesn't work:

{code:java}
<ui:remove>
    <!-- Should not be here -->
<f:metadata>
<f:viewAction actionListener="#
{forwardDispatcherBean.manageActionListener()}

" />
</f:metadata>
</ui:remove>
{code}

The reason is f:metadata is an special tag. In MyFaces there is a SAX handler that detect this tag and exclude everything before/after this tag, but ui:remove is also an special tag, but works only after the whole file has been parsed and the AST tree is built, so if a f:metadata is inside ui:remove, the instance of ui:remove is ignored.

I'll fix it for 2.2.x branch.

> Outcommented f:metadata will be also executed
> ---------------------------------------------
>
>                 Key: MYFACES-3959
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3959
>             Project: MyFaces Core
>          Issue Type: Bug
>    Affects Versions: 2.2.7
>         Environment: tomcat 7
> windows 7
>            Reporter: Artur Sommer
>            Assignee: Thomas Andraschko
>            Priority: Minor
>
> This outcommented code in a jsf page will be executed but is outcommented.
> <!-- 
> <f:metadata>
> 	<f:viewAction actionListener="#{forwardDispatcherBean.manageActionListener()}" />
> </f:metadata>
>  -->



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)