PDA

View Full Version : In EXT GWT-duplicate records check in pagingGrid



Diya
27 May 2009, 4:56 AM
Hi,

Im doing duplicate records check validation for pagingGrid.In Grid, i have set 10 records per page means each page should display 10 records.I have done coding in which its check duplicate for current page i.e. for current 10 records.

My problem is i have to check duplicate for whole records which grid contain from Database.Currently,its checking for current page but it should check for all pages at a time which grid have.

below is the code snippet:


privatevoid insertCallTypeGrid() {
MasterServiceAsync masterServiceAsync = (MasterServiceAsync) Registry
.get("sampleservice");

Map data = getUserData();

String callType="";
String codedes="";

int duplicateFlag=1;
int duplicateFlag2=1;
int specialFlag1=1;
int specialFlag2=1;



if((data.get("callType") != null))
{
callType=data.get("callType").toString();
}
if((data.get("description") != null))
{
codedes=data.get("description").toString();
}

if( data.get("callType") == null )
{
MessageBox.info("Alert","Please enter Call Type", null);
}
elseif( data.get("description") == null )
{
MessageBox.info("Alert","Please enter the Description", null);
}
elseif( (data.get("callType").toString()).length() > 10 )
{
MessageBox.info("Alert","Max. Length of Call Type is 10", null);
}
elseif( (data.get("description").toString()).length() > 100 )
{
MessageBox.info("Alert","Max. Length of Description is 100", null);
}
elseif( (data.get("callType").toString()).contains("'")||(data.get("callType").toString()).contains("\"") )
{
MessageBox.info("Alert","Invalid Character !!! Call Type", null);
}
elseif( (data.get("description").toString()).contains("'")||(data.get("description").toString()).contains("\"") )
{
MessageBox.info("Alert","Invalid Character !!! in Description", null);
}
else

{
//To check Duplicate code

if(specialFlag1==1)
{
for(int i=0;i<store.getCount();i++)
{
CallTypeBean srclist = (CallTypeBean) store.getAt(i);
if(callType.equalsIgnoreCase((String)srclist.get("callType")))
{
MessageBox.info("Alert","Call Type already exists", null);
duplicateFlag=0;
break;
}
}
}

if(duplicateFlag==1 && duplicateFlag2==1)
{
masterServiceAsync.addCallType1(data, callback);
MessageBox.info("Success", "Successfully Inserted Record ", null);
}
}

}

check the code for duplicate which is in bold letter.

Please suggest me how to implement it.

Thanks in advance for your valuable suggestion.