3
I’m having a repeat problem at listing time, in my view it repeats R01 and R01, twice the same code and only then it correctly follows R02, RO3 and so on. The correct would be R01, R02, R03 and so goes. Thanks.
public void reorganizarNumerosItens() {
List<Listitem> itens = this.getItems();
if (itens != null) {
int i = 1;
for (Listitem itemAtual : itens) {
ListitemRequisitoFuncional itemReq = (ListitemRequisitoFuncional) itemAtual;
RequisitoFuncional requisitoFuncional = itemReq.getReqFuncional();
requisitoFuncional.setStrNumRequisito(this.getStrNumItemAtual(i));
i++;
itemReq.recarregaObjeto();
try {
this.bo.salvar(requisitoFuncional);
} catch (NegocioException e) {
e.printStackTrace();
}
}
}
}
public String getStrNumItemAtual(Integer numItem) {
if (numItem == 0) {
numItem +=1;
}
String strNumItem = numItem.toString();
strNumItem = strNumItem.length() < 2 ? "R0" + strNumItem : "R" + numItem;
return strNumItem;
}
only one comment, arrays start at 0 (zero) but Voce puts the variable
i
starting at 1. Once inside the function, Voce hasif(numItem == 0)
but that will never happen, because it is passing the first as1
... change toint i = 0;
– balexandre
In this case it is using the variable "i" to set the numRequisite, so it starts from 1. R01, R02, R03, etc...
– cantoni