How do you get which radio is selected within p:selectOneRadio
using javascript/jquery ?
Since the p:selectOneRadio
uses no radio tags I have no idea how to get the checked option using CSS selectors.
<p:selectOneRadio onchange="reactToChangedRadio()" >
<f:selectItem itemLabel="....." itemValue="..." />
<f:selectItem itemLabel="....." itemValue="..." />
<f:selectItem itemLabel="....." itemValue="..." />
</p:selectOneRadio>
You can use the jquery solution or choose a simple javascript solution:
See the post from CodeRanch: http://www.coderanch.com/t/210871/JSF/java/selectOneRadio-javascript-value
UPDATE: I must admit that I'm in a dept, and I'm sorry for that but yesterday I haven't had much time...
I must say that I haven't been able to get the radio value in the old fashioned javascript way:
On the other hand, this hard-coded solution works:
,but of course, because of Primefaces power, there is a server side solution(using ReuqestContext component):
The server side code:
the ReuqestContext component can be found here: http://www.primefaces.org/showcase-labs/ui/requestContext.jsf (only for PF 3)