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
Post a Comment