checkbox and radio button in <a4j:repeat> doesnt get populated in managed bean
richfacesbie79 Mar 2, 2010 5:40 PMIn the code below, checkbox and radio button's value is not getting populated in the managed bean.
Method save() gets called by a4j:commandButton.
In save() - in 'prod' object, the values for checkbox and radiobutton remains false even if I select/check them in the JSP.
Not sure who the culprit is. Thanks for your time!
JSP Code:
<rich:dataTable id="info" value="#{mainBean.abcList}" var="abcTypeBean" rowKeyVar="tableRowNum" headerClass="colHdr"
binding="#{mainBean.tableRow}" rowClasses="x,y">
<rich:column>
<a4j:repeat value="#{ abcTypeBean.abcAttributesBean}" var="abc" rowKeyVar="aborhVar" >
<tr>
<td>
<h:outputLabel value="#{ abc.abcValue}"/>
</td>
<td>
<a4j:repeat value="#{abc.defBeanList}" var="defBean" rowKeyVar="subRowVar" >
<div style="float:left;">
<h:selectOneRadio id="attrenabledRadio"
rendered="#{ defBean.selection=='R'}" layout="lineDirection">
<f:selectItem itemValue="#{ defBean.flag}" itemLabel="#{ defBean.description}" />
</h:selectOneRadio>
<h:selectBooleanCheckbox id="attrenabled" value="#{ defBean.flag}"
label="#{defBean.description}" rendered="#{ defBean.selection=='x'}"
/>
<h:outputLabel value="#{ defBean.description}" rendered="#{ defBean.selection=='C'}"/>
</div>
</a4j:repeat>
</td>
</tr>
</a4j:repeat>
</rich:column>
</rich:dataTable>
<table border="0" >
<tr><td><br></td></tr>
<tr>
<td align="right" colspan="3">
<h:commandButton value="save" action="#{mainBean.save}" />
</td>
</tr>
</table>
Managed Bean: -
public class mainBean {
private List<ABCTypeBean> abcList;
private HtmlDataTable tableRow;
private HtmlSelectBooleanCheckbox attrenabled;
private HtmlSelectOneRadio attrenabledRadio;
public save() {
int n = this.tableRow.getRowCount();
for (int i = 0; i < n; i++) {
this.tableRow.setRowIndex(i);
if (enabled.isSelected()) {
ABCTypeBean prod =(ABCTypeBean)tableRow.getRowData();
}
}
ABC Bean: -
public class ABCTypeBean {
private List<ABCAttributesBean> abcAttributesBean;
public void setABCAttributesBean(List<ABCAttributesBean> abcAttributesBean) {
this.abcAttributesBean = abcAttributesBean;
}
public List<ABCAttributesBean> getABCAttributesBean() {
return abcAttributesBean;
}
}
ABCAttributeBean
public class ABCAttributeBean {
private List<DEFBean> defBeanList;
public void setDefBeanList(List<DEFBean> defBeanList) {
this.defBeanList = defBeanList;
}
public List<DEFBean> getDefBeanList() {
return defBeanList;
}
}
public class DEFBean {
private boolean flag;
private String selection;
private String description;
public void setFlag(boolean flag) {
this.flag = flag;
}
public boolean isFlag() {
return flag;
}
public void setDescription(String description) {
this.description = description;
}
public String getSelection() {
return selection;
}
public void setSelection(String selection) {
this.selection = selection;
}
}