public boolean dupValidate(String p_prodcode) {
System.out.println("Duplicate Validtion 1");
ViewObjectImpl vo = (ViewObjectImpl)CommonCode.getAM().findViewObject("PiProdPriceDefnVO2"); Row cRow = vo.getCurrentRow(); // Create a Iterator to Iterate Over the ViewObject Vo
// There is a also a method called vo.getRowSetIterator() but it is advised to use //vo.createRowSetIterator(null)
Integer count = 0;
RowSetIterator rsi = vo.createRowSetIterator(null);
while (rsi.hasNext()) {
Row rw = rsi.next();
if(rw != cRow){
if (rw.getAttribute("ProdCode") != null) {
String prod = (String)rw.getAttribute("ProdCode");
System.out.println("getattrib " + prod + " vceprod " + p_prodcode); if(prod.equalsIgnoreCase(p_prodcode)){
count = 1;
}
}
}
}
// Closing the iterator is advised after the use
rsi.closeRowSetIterator();
if(count == 1){
CommonCode.errmsg("Product code "+p_prodcode+" cannot be duplicate","");
return true;
}
return false;
}
------------------------------------
checking at ValueChangeEvent
------------------------------
if (dupValidate((String)vce.getNewValue())) { // checking duplicate rows
System.out.println("Trying to clear product");
setProdCodeNull(rdtl);
return;
}
--------------------------------
public void setProdCodeNull(Row currenttFow){
currenttFow.setAttribute("ProdCode",null);
currenttFow.setAttribute("CurPrice",null);
currenttFow.setAttribute("CurFromDt",null);
currenttFow.setAttribute("CurToDt",null);
AdfFacesContext.getCurrentInstance().addPartialTarget(getProdCodeId());
// AdfFacesContext.getCurrentInstance().addPartialTarget(getT1());
}
No comments:
Post a Comment