How to update HTML elements using javascript id with JSF?
843844Mar 26 2008 — edited Mar 28 2008Dear all,
I'm quiet new to JSF and I'm facing some problems when using Javascript with JSF. I think this problem is linked to the version of JSF (1.1) but I'm forced to use it as I'm running the application with Weblogic 9.2, which is J2EE 1.4 compliant.
The problem is the following: I would like to update a part of a table using ajax. For the moment this works well without JSF. I have a SPAN element with an id which is updated using javascript. The javascript runs each x seconds automatically and the SPAN element is updated each times. I have several SPAN element with a different id for each of them.
I have somethings like that:
<span id="id1"></span>
<span id="id2"></span>
<span id="id3"></span>
...
and
document.getElementById(target).innerHTML = results;
which is run every x seconds.
The SPAN elements are built dynamically in order to build unique ids. For the moment this is done using xsl transform.
I would like to do the same thing using JSF. The problem is that it is impossible to include HTML elements inside JSF components! Thus, I cannit build my SPAN elements and then I cannot update the rows using ajax.
Here is what I have in my JSP:
<h:dataTable value="#{mybean.mylist}" var="myvar">
<h:column><h:outputText value="#{myvar.something}"/></h:column>
<h:column><span id="#{myvar.uniqueid}"></span></h:column>
</h:dataTable>
The fact is that it is impossible to set the id of a JSF component so I cannot use my Javascript method. Here I would like to update the values of my second column using ajax every x seconds.
What can I do to have the same behavior using JSF components? I'm currrently using the JBoss RichFaces implementation instead of the standards JSF components but it is the same thing.
I tested it in a JSF 1.2 environnement and it works fine!!! I'm able to change the id of the HTML SPAN element without any problem!!! Is there a workaround for this. I'm really stuck!
Hope you can help,
Thanks in advance.