I am having requirement to add dynamic dropdown and text boxes using JSD 2.x. Below is the JSF code I have written:
Java code I need to create multiple BenificiaryBean but don't know how to retrieve parameter values from requesthashmap as JSF generates name dynamically:
Below is sample jsf code:
<ui:repeat var="beneficiaryBean" value="#{customerContactBean.listBeneficiaryBean}"><tr>
<td><h:inputText id="fullName" value="#{beneficiaryBean.fullName}"></h:inputText></td>
<td><h:selectOneMenu id="gender" value="#{beneficiaryBean.gender}"> <f:selectItem itemValue="MALE" itemLabel="Male" /><f:selectItem itemValue="FEMALE" itemLabel="Female" /></h:selectOneMenu></td>
<td><h:inputText id="age" value="#{beneficiaryBean.age}"></h:inputText></td>
<td><h:selectOneMenu id="profileId" value="#{beneficiaryBean.profileId}"> <f:selectItems value="#{beneficiaryBean.profileValues}"
public List<BenificiaryBean> addBeneficiary(){
Map<String,String[]> requestParameters = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterValuesMap();
listBeneficiaryBean = new ArrayList<BenificiaryBean>();
while(requestParameters.entrySet().iterator().hasNext())
{
BenificiaryBean temp = new BenificiaryBean();
temp.setAge(?);
temp.setFullName(?);
temp.setGender(?);
temp.setProfileId(?);
listBeneficiaryBean.add(temp);
}
showRemoveButton = true;
return listBeneficiaryBean;
}
What should be values of ?
be?