Actually what I wanted to do is passing a javascript value to an entity bean. so I got this.
<h:form class="myForm">
              <p id="test">Please enter your name:sadfas</p><br/>
              <h:inputText value="#{annotation.content}" /><br/>
              <h:inputHidden id="hidden" value="#{annotation.time}"/>
              <a4j:commandButton value="save" onclick="setTime()" action="#{annotationManager.addIn(annotation)}" reRender="annotationTable"/>
</h:form>
and with a javascript function
<script type="text/javascript">
              function setTime()
                    {
                              var time = Math.round($f().getTime());          // this is the time I want to pass to the entity bean
                              document.getElementById('myForm:hidden').value = time;          // problem occurs here
                              document.getElementById("test").innerHTML = time;               // I use this to test whether the function is actually performed
                    }
</script>
With above code, when I click on the commandButton in the page, nothing happened at all, but if I delete this line
 
document.getElementById('myForm:hidden').value = time;          // problem occurs here
 
The programe works. It change the value of <p id="test">, which means it performed the javascript function.
 
I am not sure if this is the correct way to do this, but I have searched for the solution for few hours and none of them helped.
 
I think the problem is that program can't get the value from the hidden field through "document.getElementById('myForm:hidden').value"
 
Thank you in advance.