1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
public class UnitCoeffForm implements java.io.Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
....
....
...
private List <UnitCoeffTabRow> _unitCoeffTab;
public UnitCoeffForm(){
System.out.println("Init - UnitCoeffForm");
}
private void createDataAttack(UnitCoeffs us){
this._unitCoeffTab = new ArrayList <UnitCoeffTabRow>();
TypeUnits tu = getListTypeUnits();
if (us!=null){
List <UnitCoeff> ucs = us.get_UnitCoeffAttaks();
if (ucs.size()>0){
for (int i=0;i<ucs.size();i++){
UnitCoeff temp = ucs.get(i);
Integer id = temp.get_tbUCTypeDef();
String desc = tu.getTypeUnit(temp.get_tbUCTypeDef()).get_tbTypeUnitDescription();
int j = unitExiste(id);
if (j>=0){
_unitCoeffTab.get(j).set_coeffAttack(temp.get_tbUCNbHexagone(), temp.get_tbUCAttack());
}else{
UnitCoeffTabRow t = new UnitCoeffTabRow();
t.set_unitId(id);
t.set_unitName(desc);
t.set_coeffAttack(temp.get_tbUCNbHexagone(), temp.get_tbUCAttack());
_unitCoeffTab.add(t);
}
}
}
}
}
private int unitExiste(Integer id){
if ((_unitCoeffTab!=null)&&(_unitCoeffTab.size()>0)){
for (int i=0;i<_unitCoeffTab.size();i++){
if (_unitCoeffTab.get(i).get_unitId()==id){
return i;
}
}
}
return -1;
}
private UnitCoeffs getListCoeffs(){
Object obj = FacesContext.getCurrentInstance().getApplication().getVariableResolver()
.resolveVariable(FacesContext.getCurrentInstance(), "unitCoeffs");
return (UnitCoeffs) obj;
}
private TypeUnits getListTypeUnits(){
Object obj = FacesContext.getCurrentInstance().getApplication().getVariableResolver()
.resolveVariable(FacesContext.getCurrentInstance(), "typeUnits");
return (TypeUnits) obj;
}
public String save(){
System.out.println("save");
System.out.println(this._unitCoeffTab.size());
for (int i=0;i<this._unitCoeffTab.size();i++){
System.out.println(this._unitCoeffTab.get(i).get_coeffAttack1());
}
return "ok";
}
public List<UnitCoeffTabRow> get_tab() {
return _unitCoeffTab;
}
// autre getters et setters...
} |
Partager