Using JavaScript with JSF and Facelets -


i use javascript manipulate hidden input fields in jsf/facelets page. when page loads, need set hidden field color depth of client.

from facelet:

<body onload="setcolordepth(document.getelementbyid(?????);">  <h:form>   <h:inputhidden value="#{login.colordepth}" id="colordepth" /> </h:form> 

when jsf processes page, of course changing ids of elements. what's best way reference these elements javascript code?

you'll want set id of form you'll know is. you'll able construct actual element id.

<body onload="setcolordepth(document.getelementbyid('myform:colordepth');">  <h:form id="myform">   <h:inputhidden value="#{login.colordepth}" id="colordepth" /> </h:form> 

if don't want set form's id field, find @ runtime, so:

<body onload="setcolordepth(document.getelementbyid(document.forms[0].id + ':colordepth');"> 

Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -