0

I have a PF selectOneRadio implemented on a modal-dialog

<p:selectOneRadio value="true" onchange="doSomething()" widgetVar="idWidget" >
    <f:selectItem itemLabel="1" itemValue="true" />
    <f:selectItem itemLabel="2" itemValue="false" />
</p:selectOneRadio>

when i click a botton i need to restore the default value (the value of selectOneRadio to true) . I need so of a JQUERY function or JS or PF. I try with PF('idWidget').select($('.ui-radiobutton-box').first()); it selects the value of selectOneRadio outside the dialog, although the widgetVar has another name. I don't know what to use anymore . Please help me.

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
  • In other words, the `$('.ui-radiobutton-box').first()` part didn't return the desired radio button at all. Probably you have multiple `$('.ui-radiobutton-box')` elements within the HTML page of which the first one actually isn't the one inside the dialog? Can't you just edit the jQuery selector `'.ui-radiobutton-box'` to match the right one? Not really a JSF problem let alone Java. – BalusC Mar 19 '19 at 20:40
  • 1
    You found https://stackoverflow.com/questions/28091317/how-to-set-the-value-of-pselectoneradio-with-client-side-api I presume? Did you also see the 'better' solution in there? – Kukeltje Mar 19 '19 at 20:46
  • @Kukeltje I had not seen that question, I took the instruction from another part, however even the code of the best answer does not work – Netrill DellaLuce Mar 19 '19 at 21:10
  • @BalusC I tried to change the selector, but it only works if I refer only to that specific class – Netrill DellaLuce Mar 19 '19 at 21:15
  • No, but that is because what @BalusC already mentioned, your selector is wrong. But that is beyond the scope of the question. And if you changed your selector (to what?) and it is still not working, experiment separately in a browser developer tool with the jquery selectors until you have the right selector. Or post the relevant html in a new question and ask, just with jquery as a tag, what the right selector is to get specific elements. – Kukeltje Mar 19 '19 at 21:18
  • One moment, I tried to change the name of the f: selectItem, putting a value that was not repeated in the others but unique. The instruction taken from the other question: PF ('selectOneRadioWV'). Jq.find ('input: radio [value = "1"] '). Parent (). Next (). Trigger (' click.selectOneRadio ') now works. Thank you so much guys! – Netrill DellaLuce Mar 19 '19 at 21:39

0 Answers0