<legend id='bOPtZ'><style id='bOPtZ'><dir id='bOPtZ'><q id='bOPtZ'></q></dir></style></legend>
    1. <i id='bOPtZ'><tr id='bOPtZ'><dt id='bOPtZ'><q id='bOPtZ'><span id='bOPtZ'><b id='bOPtZ'><form id='bOPtZ'><ins id='bOPtZ'></ins><ul id='bOPtZ'></ul><sub id='bOPtZ'></sub></form><legend id='bOPtZ'></legend><bdo id='bOPtZ'><pre id='bOPtZ'><center id='bOPtZ'></center></pre></bdo></b><th id='bOPtZ'></th></span></q></dt></tr></i><div id='bOPtZ'><tfoot id='bOPtZ'></tfoot><dl id='bOPtZ'><fieldset id='bOPtZ'></fieldset></dl></div>

      <small id='bOPtZ'></small><noframes id='bOPtZ'>

        <tfoot id='bOPtZ'></tfoot>
          <bdo id='bOPtZ'></bdo><ul id='bOPtZ'></ul>

        如何将 JavaScript 值传递给 JSF EL 和支持 bean?

        时间:2023-09-06

        • <legend id='7ZCg8'><style id='7ZCg8'><dir id='7ZCg8'><q id='7ZCg8'></q></dir></style></legend>

            • <i id='7ZCg8'><tr id='7ZCg8'><dt id='7ZCg8'><q id='7ZCg8'><span id='7ZCg8'><b id='7ZCg8'><form id='7ZCg8'><ins id='7ZCg8'></ins><ul id='7ZCg8'></ul><sub id='7ZCg8'></sub></form><legend id='7ZCg8'></legend><bdo id='7ZCg8'><pre id='7ZCg8'><center id='7ZCg8'></center></pre></bdo></b><th id='7ZCg8'></th></span></q></dt></tr></i><div id='7ZCg8'><tfoot id='7ZCg8'></tfoot><dl id='7ZCg8'><fieldset id='7ZCg8'></fieldset></dl></div>
            • <tfoot id='7ZCg8'></tfoot>

                  <tbody id='7ZCg8'></tbody>
                  <bdo id='7ZCg8'></bdo><ul id='7ZCg8'></ul>
                • <small id='7ZCg8'></small><noframes id='7ZCg8'>

                  本文介绍了如何将 JavaScript 值传递给 JSF EL 和支持 bean?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在做 JSF 地理定位服务,我需要将纬度和经度传递给 bean 进行处理.HTML5 允许使用 JavaScript 获取位置,例如在 http://code.google.com/p/geo-location-javascript/.将以下代码放入 JSF 页面会显示带有 GPS 坐标的警报

                  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 done in http://code.google.com/p/geo-location-javascript/. Putting following code to JSF page shows alert with GPS coordinates

                  <script>
                      if (geo_position_js.init()) {
                          geo_position_js.getCurrentPosition(success_callback,error_callback,{enableHighAccuracy:true,options:5000});
                      } else {
                          alert("Functionality not available");
                      }
                      function success_callback(p) {
                          alert('lat='+p.coords.latitude.toFixed(2)+';lon='+p.coords.longitude.toFixed(2));
                      }
                  
                      function error_callback(p) {
                          alert('error='+p.message);
                      }
                  </script>
                  

                  如何使用 p.coords.latitude.toFixed(2) 值将其传递给例如 h:inputtext 组件?

                  How to use p.coords.latitude.toFixed(2) value to pass it for example to h:inputtext component?

                  推荐答案

                  你需要意识到 JSF 在 webserver 上运行并产生一堆 HTML/CSS/JS 代码从 webserver 发送到 webbrowser 并且 webbrowser 只运行HTML/CSS/JS.右键单击 webbrowser 中的页面并选择查看源代码.代替 <h:inputText> 你会看到类似

                  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" />
                  

                  在 JS 中,您可以使用 document 函数轻松地从 HTML DOM 中获取 HTML 元素并对其进行修改.

                  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';
                  

                  另见:

                  • Java/JSP/JSF与JavaScript之间的通信
                  • 这篇关于如何将 JavaScript 值传递给 JSF EL 和支持 bean?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Safari 5 中的地理位置 下一篇:Web Workers 中的 HTML5 navigator.geolocation

                  相关文章

                  最新文章

                • <tfoot id='2fx38'></tfoot>
                  • <bdo id='2fx38'></bdo><ul id='2fx38'></ul>

                  1. <legend id='2fx38'><style id='2fx38'><dir id='2fx38'><q id='2fx38'></q></dir></style></legend>
                    1. <small id='2fx38'></small><noframes id='2fx38'>

                      <i id='2fx38'><tr id='2fx38'><dt id='2fx38'><q id='2fx38'><span id='2fx38'><b id='2fx38'><form id='2fx38'><ins id='2fx38'></ins><ul id='2fx38'></ul><sub id='2fx38'></sub></form><legend id='2fx38'></legend><bdo id='2fx38'><pre id='2fx38'><center id='2fx38'></center></pre></bdo></b><th id='2fx38'></th></span></q></dt></tr></i><div id='2fx38'><tfoot id='2fx38'></tfoot><dl id='2fx38'><fieldset id='2fx38'></fieldset></dl></div>