You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Mathias Werlitz (JIRA)" <de...@myfaces.apache.org> on 2012/07/17 16:55:34 UTC
[jira] [Created] (MYFACES-3584) h:commandLink renders onclick
JavaScript referencing a non-existent HTML id
Mathias Werlitz created MYFACES-3584:
----------------------------------------
Summary: 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
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
[jira] [Commented] (MYFACES-3584) h:commandLink renders onclick
JavaScript referencing a non-existent HTML id
Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
[ 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
[jira] [Commented] (MYFACES-3584) h:commandLink renders onclick
JavaScript referencing a non-existent HTML id
Posted by "Mathias Werlitz (JIRA)" <de...@myfaces.apache.org>.
[ https://issues.apache.org/jira/browse/MYFACES-3584?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13421252#comment-13421252 ]
Mathias Werlitz commented on MYFACES-3584:
------------------------------------------
Well this issue may cause problems with other JS event handlers too.
> 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
[jira] [Commented] (MYFACES-3584) h:commandLink renders onclick
JavaScript referencing a non-existent HTML id
Posted by "Mathias Werlitz (JIRA)" <de...@myfaces.apache.org>.
[ https://issues.apache.org/jira/browse/MYFACES-3584?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13421335#comment-13421335 ]
Mathias Werlitz commented on MYFACES-3584:
------------------------------------------
You are right. If for example an ajax script is added for the other event handlers the id is properly written.
Thanks for the fast fix.
> 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
[jira] [Resolved] (MYFACES-3584) h:commandLink renders onclick
JavaScript referencing a non-existent HTML id
Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
[ https://issues.apache.org/jira/browse/MYFACES-3584?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Leonardo Uribe resolved MYFACES-3584.
-------------------------------------
Resolution: Fixed
Fix Version/s: 2.1.9
2.0.15
Assignee: Leonardo Uribe
I just add the check to force id rendering if onclick property is defined.
> 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