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

后端 未结 1 829
一个人的身影
一个人的身影 2020-12-06 18:53

I am doing JSF geolocation service where I need to pass latitude and longitude to bean for processing. HTML5 allows getting location with JavaScript, for example like is don

1条回答
  •  太阳男子
    2020-12-06 19:37

    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 you'll see something like

    
    

    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:

    • Communication between Java/JSP/JSF and JavaScript

    0 讨论(0)
提交回复
热议问题