Java 当我尝试从selectManyCheckbox检索选中项时,将循环到无穷大
我想从复选框中恢复选中项的列表,问题是当我迭代列表以检索选中项时,指令将循环到无穷大 这是我的代码: JSF:Java 当我尝试从selectManyCheckbox检索选中项时,将循环到无穷大,java,jsf,Java,Jsf,我想从复选框中恢复选中项的列表,问题是当我迭代列表以检索选中项时,指令将循环到无穷大 这是我的代码: JSF: <h:selectManyCheckbox value="#{TestAjax.selectedItemscheckbox}"> <f:selectItem itemValue="priority.pname" itemLabel="By priority" /> <f:selectItem itemValue="project.pname" item
<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();
}
代码:
<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();
}
公共类TestAjax{
private ArrayList selectedItemscheckbox;//用于分组的复选框列表
public ArrayList getSelectedItemscheckbox(){
返回selectedItemscheckbox;
}
公共无效设置selectedItemscheckbox(ArrayList selectedItemscheckbox){
this.selectedItemscheckbox=selectedItemscheckbox;
}
public void CreateQueryNumber()
{
Iterator it=selectedItemscheckbox.Iterator();
System.out.println(“Checkedddddd”+selectedItemscheckbox);
while(it.hasNext())==>循环到无穷远
{
System.out.println(“one”+it.toString());
select=“选择计数(jiraissue.id)作为nb”;
from=“jiraissue j,优先级pr,项目项目”;
其中=“j.project=proj.id”;
jointure=“j.priority=pr.id”;
groupBy=“groupBy”+it.toString();
}
}您没有对它进行任何调用。next()。若要解决此问题,您可以在循环末尾添加一个it.next():
while(it.hasNext()){
.... bla bla bla ....
it.next();
}
或者使用类似于:
Object obj;
while((obj = it.next()) != null){
.... bla bla bla ....
}
您没有对它进行任何调用。next()。若要修复此问题,您可以在循环末尾添加一个it.next():
while(it.hasNext()){
.... bla bla bla ....
it.next();
}
或者使用类似于:
Object obj;
while((obj = it.next()) != null){
.... bla bla bla ....
}
您没有调用
it.next()
将迭代器跳转到下一个值
while(it.hasNext())
{
String i_str = it.next().toString();
System.out.println( "one"+ i_str );
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 "+i_str;
}
您没有调用
it.next()
将迭代器跳转到下一个值
while(it.hasNext())
{
String i_str = it.next().toString();
System.out.println( "one"+ i_str );
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 "+i_str;
}
您仍然使用Java 1.4或更高版本吗?您已经使用1.5或更高版本了,对吗?请使用
您仍然使用Java 1.4或更高版本吗?您已经使用1.5或更高版本了,对吗?请使用
,谢谢我把它放了。toString()代替了它。next(),这是因为我还没有喝咖啡:),谢谢我把它放了。toString()代替了它。next()),这是因为我还没有喝咖啡:)谢谢,我想问你,使用这个循环有什么好处?谢谢,我想问你,使用这个循环有什么好处?