我想从复选框中恢复选中的项目列表,当我迭代列表以检索项目时,问题是检查指令 while 循环到无限 这是我的代码:
JSF:
<h:selectManyCheckbox value="#{TestAjax.selectedItemscheckbox}">
<f:selectItem itemValue="priority.pname" itemLabel="By priority" />
<f:selectItem itemValue="project.pname" itemLabel="By project" />
</h:selectManyCheckbox>
代码:
public Class TestAjax {
private ArrayList<String> selectedItemscheckbox; //list of checkbox used for grouping
public ArrayList<String> getSelectedItemscheckbox() {
return selectedItemscheckbox;
}
public void setSelectedItemscheckbox(ArrayList<String> selectedItemscheckbox) {
this.selectedItemscheckbox = selectedItemscheckbox;
}
public void CreateQueryNumber()
{
Iterator it= selectedItemscheckbox.iterator();
System.out.println("checkeddddddddddd"+selectedItemscheckbox);
while(it.hasNext()) ===>loop to the infinity
{
System.out.println("one"+ it.toString());
select ="select count(jiraissue.id) as nb";
from ="jiraissue j ,priority pr ,project proj";
where="j.project=proj.id";
jointure="j.priority =pr.id";
groupBy="group by "+it.toString();
}
}
最佳答案
您没有对 it.next() 进行任何调用。要解决此问题,您可以在循环末尾添加 it.next() :
while(it.hasNext()){
.... bla bla bla ....
it.next();
}
或者使用类似的东西:
Object obj;
while((obj = it.next()) != null){
.... bla bla bla ....
}
关于java - 当我尝试从 selectManyCheckbox 检索选中的项目时, while 循环到无穷大,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6609261/