Set text in Visual JSF textfield from javascript
843844Sep 18 2009 — edited Sep 18 2009HI,
I want to pass a variable from a javascript to put into a visual jsf textfield that is connected to a Bean variable like this:
<webuijsf:textField id="myLat" style="left: 96px; top: 336px; position: absolute" text="#{CreateNewPage.latitude}"/>
I use this library: xmlns:webuijsf="http://www.sun.com/webui/webuijsf"
I found a guide for this using regular jsf-tags, but that doesn't work for the visual jsf tags. Link: http://balusc.blogspot.com/2009/05/javajspjsf-and-javascript.html
I managed though to change the field to some sort of text by using:
var lat = 'text';
document.getElementById("form1:myLat").textContent = lat;
in my javascript. But this just replaces the textfield to some stand alone text, and the variable in my Bean isn't changed at all. I tried using .value and .text instead of .textContent but it doesn't work. What am I doing wrong here? I'm new to JSF by the way. Thankful for any help.