开发者

can't get html td element using javascript in jsf application

开发者 https://www.devze.com 2022-12-14 22:35 出处:网络
and in JavaScript document.getElementById(\'myId\'); This is not working in JSF application. Howev开发者_如何学Goer, the same is working if I save the generated HTML in my system and open it .

and in JavaScript

 document.getElementById('myId');

This is not working in JSF application. Howev开发者_如何学Goer, the same is working if I save the generated HTML in my system and open it .

Any Help ?


When writing JavaScript code for a component based MVC framework which generates HTML, like JSF, you should not focus on the source code of the component based MVC framework, but on its generated HTML output.

If you can't tell this beforehand based on the source code, then you need to just open up the page in your favourite webbrowser and then rightclick the page and choose View Source. You'll see that the generated Client ID's are prepended by the ID's of the UINamingContainer components (like h:form, h:dataTable and f:subView). If you don't specify an ID for each of them, you will get an autogenerated ID like j_id_xxxx. To ease the work, you need to specify an ID for them. E.g.

<h:form id="form">

Also see this blog article for more information and hints. This blog article may also be useful to learn more about the wall between Java/JSP/JSF and JavaScript.

0

精彩评论

暂无评论...
验证码 换一张
取 消