0
votes

I am using a SelectBooleanCheckbox in a Composite Component which is rendered repeatetly with ui:repeat on the page. After pressing the Save button the page gets updated but the checkbox is unchecked even if the bean value is true.

<p:selectBooleanCheckbox id="someId" value="#{cc.attrs.item.property}"/>
#{cc.attrs.item.property}

And this is what is displayed on the page:

This gets rendered!

When i navigate to the page initialiy or after reloading the page in the Browser everything is rendered ok.

I also tried to change the submit to non-ajax and also using h:selectBooleanCheckbox but that did not change much.

========================== more code =================

page.xhtml

...
<ui:repeat id="listID" value="#{itemList}" var="listElement">
    <cc:componentWithCheckbox id="theComponent" item="#{listElement}"/>
</ui:repeat>
...

componentWithCheckbox.xhtml

<cc:interface>
<cc:attribute name="item" required="true" />
</cc:interface>

<cc:implementation>
    <div id="#{cc.clientId}">
        <p:inputText value="#{cc.attrs.item.someTextProperty}"/>
        <p:selectBooleanCheckbox id="someId" value="#{cc.attrs.item.property}"/>
        #{cc.attrs.item.property}
    </div>
</cc:implementation>

Bean

The Bean does nothing to the field. Just saves it in the DB. The value is correct in the bean and in the DB after pressing save. Just not rendered on the page.

====================== SOLUTION FROM MROD =====================

I just switched the ui:repeat in the view for c:forEach and everything was fine. :) I just needed to alter the id of the repeated element becouse with forEach every element got the same. I just added the status.index to the id to fix that.

1
Please provide the full xhtml code and managed Bean code so the situation is clear. - BholaVishwakarma
Dont mine if i have a teamviewer to check your code - BholaVishwakarma
Thanks for your offer. I cannot install teamviewer on this PC here :/ - MoYapro
Have you tried using 'c:forEach' instead of 'ui:repeat'? Can you specify which implementation of JSF you are using? - mrod
Thanks for the tip, I will try that tomorrow. - MoYapro

1 Answers

0
votes

Try using c:forEach instead of ui:repeat :)