我有一个 p:selectOneRadio 的动态列表,如下所示:
1 op1 op2 op3
2 op1 op2 op3
3 op1 op2 op3
因此,当我提交时,我想知道为第 1 行选择了哪个选项,为第 2 行选择了哪个选项,为第 3 行选择了哪个选项。我遇到的问题是我只得到最后一个选择的选项。这是我的xhtml:
<ui:repeat var="o" value="#{perfilesMB.numbers}" varStatus="status">
<p:selectOneRadio value="#{perfilesMB.number}">
<p:ajax listener="#{perfilesMB.handleCityChange}" />
<f:selectItem itemLabel="Option 1" itemValue="1" />
<f:selectItem itemLabel="Option 2" itemValue="2" />
<f:selectItem itemLabel="Option 3" itemValue="3" />
</p:selectOneRadio>
</ui:repeat>
这是我的托管bean:
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Arrays;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;
import org.springframework.dao.DataAccessException;
import javax.faces.context.FacesContext;
import javax.faces.application.FacesMessage;
import org.primefaces.event.RowEditEvent;
@ManagedBean(name="perfilesMB")
//@RequestScoped
@SessionScoped
public class PerfilesManagedBean implements Serializable{
private List<String> numbers;
private String number;
public List<String> getNumbers() {
return numbers;
}
public void setNumbers(List<String> numbers) {
this.numbers = numbers;
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
//private String nivel;
//private int id_seccion;
public PerfilesManagedBean() {
niveles = new ArrayList<String>();
numbers = new ArrayList<String>();
for (int i = 0; i < 3; i++) {
numbers.add("" + i);
}
}
public String sendData(){
System.out.println("Number: " + number);
return "";
}
}
我该如何解决?提前致谢