0

I have the following code which generates the radio button properly.

<c:forEach items="#{sampleController.modelVo.valuesList}" var="valueVo">
                             <p:selectOneRadio 
                                id="pickedSdlp_#{valueVo.id}" 
                                value="#{sampleController.selectedValue}" 
                                layout="responsive" 
                                columns="1" 
                                converter="omnifaces.SelectItemsConverter" >
                                    <f:selectItem 
                                        id="valueVo#{valueVo.id}" 
                                        itemLabel="#{valueVo.valueVoDesc}" 
                                        itemValue="#{valueVo}">
                                    </f:selectItem>
                            </p:selectOneRadio>
                             <p:selectManyCheckbox 
                                id="timeBlocks_#{valueVo.id}" 
                                value="#{valueVo.timeId}" 
                                layout="responsive" 
                                columns="1">
                                <f:selectItems value="#{valueVo.subValueList}" var="valueVoTime" itemLabel="#{valueVoTime.from} #{valueVoTime.to}" itemValue="#{valueVoTime.id}" />
                            </p:selectManyCheckbox>
                        </c:forEach>

Is it possible to hide/show p:selectManyCheckbox based on the value selected? the value is actually based on voList.canShow == 'Y', if Y then show else hide it.

Radio buttons are dynamically created so not sure how to achieve this.

I am able to generate the following and highlighted the radio selected under each radio button check boxes are generated but how to hide/show them based on the radio value(ON/OFF):

enter image description here

halfer
  • 19,824
  • 17
  • 99
  • 186
Joe
  • 4,460
  • 19
  • 60
  • 106
  • 2
    Learn about ajax... – Kukeltje Jun 08 '20 at 12:21
  • @Kukeltje thanks, yes i tried with but could not get as how to hide or show "p:selectManyCheckbox " as this p:selectManyCheckbox also is dynamically generated. would be helpful if you give me some hint or little more explanation when you are free. +1 for spending time and posting here. – Joe Jun 08 '20 at 13:48
  • If you tried ajax (and that is needed) add that to the question, the initial question. Now it seems like you do not know it. And for updating, well, as long as there is no [mcve] it is hard to tell how the 'generation' of the `p:selectManyCheckbox` plays a role... Oh and try with a plain JSF component too, to see if that works. If not, it is most likely plain jsf related (and I think it is). Javascript as a a tag is certainly wrong – Kukeltje Jun 08 '20 at 14:03
  • 2
    Oh wait.... I only now see you try to 'generate' a `` inside a `f:selectItem`... That will never work... What UI did you have in mind – Kukeltje Jun 08 '20 at 14:07
  • @Kukeltje, Thanks again, have to generated radio buttons based on the list provided and each radio button(not all) will have some values, if the values exist then show the if other radio button is clicked and if that has values then hide the previous one and show this – Joe Jun 08 '20 at 14:11
  • A radio button can only have one value... True or false or rather the set of radio buttons can only have one of them being true. They cannot have other values. So an 'if the values exist' is impossible. Take a step back and describe functionally what you need, not how you **think** the ui should be technically – Kukeltje Jun 08 '20 at 14:30
  • @Kukeltje, Please check the question, i have edited and added the screenshot. Please suggest if there any is possible way of handling this. Thanks – Joe Jun 08 '20 at 16:31
  • it is hard to see how you use beans/lists etc but forvthe solution, the custom layout of the radipbutton is what you need https://www.primefaces.org/showcase/ui/input/oneRadio.xhtml – Kukeltje Jun 08 '20 at 16:50
  • Thanks for the changed code but 1: It should be the original code... Question should not be chameleonized after comments... The **answer** might go in this direction, but it looks like a completely different solution.You know have many independent radio buttons instead of 1 'group' So you could click each of them. The solution is like commented in the custom layout of the radionbuttons. And the show/hide is then the only remaining 'issue' Please revert to the original code. – Kukeltje Jun 09 '20 at 11:51
  • @Kukeltje, sure, please give me some time, will do it – Joe Jun 09 '20 at 12:51

0 Answers0