How to pass JavaScript values to JSF EL and backing bean?

旧巷老猫 提交于 2019-11-28 01:17:05

You need to realize that JSF runs at webserver and produces a bunch of HTML/CSS/JS code which get sent from webserver to webbrowser and that the webbrowser only runs HTML/CSS/JS. Rightclick the page in webbrowser and choose View Source. In place of the <h:inputText> you'll see something like

<input type="text" id="formid:inputid" />

In JS, you can easily grab HTML elements from the HTML DOM using document functions and alter it.

var input = document.getElementById('formid:inputid');
input.value = 'new value';

See also:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!