This content has been marked as final.
Show 2 replies
-
1. Submit JavaScript value to a4j:commandLink
ilya40umov Feb 2, 2011 11:23 AM (in response to strannik)Try to use a4j:actionparam
http://docs.jboss.org/richfaces/latest_3_3_X/en/devguide/html/a4j_actionparam.html
This link says:
It is possible to use JavaScript expression or function in the "value" attribute. In this case the "noEscape" attribute should be set to "true". The result of this JavaScript invocation is sent to the server as a value of <a4j:actionparam> .
-
2. Re: Submit JavaScript value to a4j:commandLink
strannik Feb 2, 2011 1:43 PM (in response to ilya40umov)Thanks, Ilya.
It works
<a4j:commandLink action="#{myController.vote(myBean)}" value="#{msg['rating']}"> <a4j:actionparam name="h" value="getSelectedMark()" assignTo="#{myBean.mark}" noEscape="true" /> </a4j:commandLink> <script type="text/javascript" language="javascript"> //<![CDATA[ function getSelectedMark() { var rates = document.getElementsByName("rating"); for (i = 0; i < rates.length; i++) { if(rates[i].checked == true) { return rates[i].value; } } return 0; } //]]> </script>