myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Leonardo Uribe (JIRA)" <...@myfaces.apache.org>
Subject [jira] [Commented] (MYFACES-3584) h:commandLink renders onclick JavaScript referencing a non-existent HTML id
Date Tue, 24 Jul 2012 10:28:34 GMT

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

Leonardo Uribe commented on MYFACES-3584:
-----------------------------------------

In this case, the problem is the onclick for h:commandLink is special, because it requires
to add a submit script, and that script is the one who requires the id. The other event handlers
are ok.
                
> h:commandLink renders onclick JavaScript referencing a non-existent HTML id
> ---------------------------------------------------------------------------
>
>                 Key: MYFACES-3584
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3584
>             Project: MyFaces Core
>          Issue Type: Bug
>    Affects Versions: 2.1.8
>            Reporter: Mathias Werlitz
>            Assignee: Leonardo Uribe
>             Fix For: 2.0.15, 2.1.9
>
>
> If you do not set the id of a h:commandLink explicitly the generated onclick JavaScript
references an HTML id (client id of the command link) that was no rendered in the response.
> Example:
> <h:form id="form">
>   <script>
>     function myFunction(element) {
>   	  alert(element.id);
>   	  return false;
>     }
>   </script>
>   <h:commandLink value="commandLink" onclick="return myFunction(this);" />
> </h:form>
> renders:
> <a href="#" onclick="return jsf.util.chain(document.getElementById('form:j_id_6'),
event,'return myFunction(this);', 'return myfaces.oam.submitForm(\'form\',\'form:j_id_6\');');">commandLink</a>
> The HTML id "form:j_id_6" is referenced here in script, but is not rendered. This also
happens if no onclick is defined explicitly for h:commandLink.
> In this example passing the "this"-JavaScript reference inside the JS function will be
the window object. Thats an error and a fallback if the supplied id could not be found. The
link DOM element would be expected here.
> If the id of the h:commandLink is set explicitly, the "this"-JavaScript reference inside
the JS function will be the correct link DOM element.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message