i have renderd checkboxes. when i select checkbox that checkbox value shoud be displayed in panel.i have written code for this but not worked
<h:selectManyCheckbox id="chkedition" value="#{newspaperBean.selectedEditions}" layout="lineDirection" styleClass="nostyle">
<f:selectItems value="#{newspaperBean.searchEditionByNewspaper()}" var="item" itemLabel="#{item.editionName}" itemValue="#{item.editionName}"/>
<f:ajax render="display" event="select"/>
</h:selectManyCheckbox>
</td>
</tr>
<tr>
<td colspan="2">
<p:panel id="display" header="You have selected">
<c:forEach items="#{newspaperBean.selectedEditions}" var="it">
<h:outputText value="#{it}"/><br/>
</c:forEach>
</p:panel>
</td>
</tr>
this worked when i submit form but i want that when i select checkbox.
Remove the
event="select"attribute. This is the incorrect event to hook on. It’s only triggered when you select any text in input fields and textareas, not when you click the checkbox.The default event is already
valueChangewhich will resolve toclickin checkboxes and this is exactly what you need. You can if necessary explicitly specify it byevent="click", but as said, it’s the default value already, so just omit it.Another potential problem is the
<c:forEach>in the panel. This will fail if the bean is view scoped because it runs during view build time and get its own separate instance of the view scoped bean which may not contain the submitted data. You’d need to use<ui:repeat>instead.See also: