Methods to Iterate Row in OAF


Below are the methods to Iterate rows in OAF.

 

 

 

/* Method — 1 */

public String account2Validation(OAViewObject vo, OAViewRowImpl row, String k)

{

int counter=0;

if((vo!=null))

{

 

//for(xxcactBankValiVORowImpl row=(xxcactBankValiVORowImpl)vo.first(); row!=null; row=(xxcactBankValiVORowImpl)vo.next())//Where the class is rowImpl which can be used within the controller code

for(row = (OAViewRowImpl) vo.first(); row!=null; row = (OAViewRowImpl) vo.next()) //Iterating using For loop

{

String primaryKey=(row.getAttribute(“AccNo”)).toString();

// String primaryKey=(row.getAccNo()).toString(); //This apples when the variable is declared with directly with the class like –> (xxcactBankValiVORowImpl row)

System.out.println(“Value of the Obtained Value”+(row.getAttribute(“AccNo”)).toString());

if (primaryKey.compareTo(k) == 0)

{

System.out.println(“Values Match and “+primaryKey);

counter++;

break;

}

else

{

System.out.println();

}

 

}

try{

if(counter==0)

{

OAException message = new OAException(“This is a invalid number.”,OAException.ERROR);

// return “invalid”;

pageContext.putDialogMessage(message);

}

}

catch(OAException e)

{

System.out.println(e);

}

 

}

return counter+””; //This is Actually a fastest method to convert a int to String

}

 

 

 

 

/* Method –> 2 */

 

 

public String account1Validation(OAViewObject vo, OAViewRowImpl row, String k, String col)

{

System.out.println(“Control came to Account Validation”);

int counter=0; // Introducing a counter variable for us to count

String iteratedval=null; //Iteration varable

System.out.println(k);

if((vo!=null))

{

vo.first();

while(vo.hasNext()) // Loop through VO rows

{

if(vo.getCurrentRow().getAttribute(col)!=null)

iteratedval=(vo.getCurrentRow().getAttribute(col).toString());

System.out.println(“———————————————->”+vo.getCurrentRow().getAttribute(col)+”Something Comes in “+iteratedval);

if (iteratedval.compareTo(k) == 0)

{

System.out.println(“Values Match and “+iteratedval);

counter++;

break;

}

vo.next();

}

try

{

if(counter==0)

{

OAException message = new OAException(“This is a invalid number.”,OAException.ERROR);

pageContext.putDialogMessage(message);

}

}

catch(OAException e)

{

System.out.println(e);

}

}

return counter+””; //This is Actually a fastest method to convert a int to String

}

 

 

 

/* Method –> 3 Using RowSetIterator*/

 

 

public String accountValidation(OAViewObject vo, OAViewRowImpl row, String k1, String col)

{

int counter = 0;

int k=Integer.parseInt(k); //Parsing Value To int

xxcactBankValiVORowImpl row = null; //Assigning a variable for Row to get Attributes

vo.getRowCount(); //Getting the Values of Row Count This is important because when FetchedRowCount() method is called

int fetchedRowCount = vo.getFetchedRowCount(); //Obtaining the Fetched Row Count

System.out.println(“Value Of Fetched Row Count “+fetchedRowCount);

RowSetIterator rowsetiterator = vo.createRowSetIterator(“MyTestIter”); //creating a Iterator

System.out.println(“Row Iterator has been Created”+rowsetiterator);

if (fetchedRowCount > 0)

{

rowsetiterator.setRangeStart(0); //Assiging the Range

rowsetiterator.setRangeSize(fetchedRowCount);

for (int i = 0; i < fetchedRowCount; i++)

{

row = (xxcactBankValiVORowImpl)rowsetiterator.getRowAtRangeIndex(i); //Iterating and passing values for each row to get printed

System.out.println(“xxcactBankValiVO Current Row ————————————————————->”+vo.getCurrentRowIndex()+”Acc No Before”+row.getAccNo());

 

System.out.println(“Obtaining the from Row Set Iterator”+row);

Number primaryKey = row.getAccNo();// Getting the Value of Each Attributes

int b=row.getAttributeCount(); //Obtainging the Attribute Count

System.out.println(“Value of Account Number”+primaryKey+” Value of Balance”+a+”Value of Attribute Count “+b);

if (primaryKey.compareTo(k) == 0)

{

System.out.println(“Values Match and “+primaryKey);

counter++;

break;

}

}

 

 

}

 

try

{

if(counter==0)

{

OAException message = new OAException(“This is a invalid number.”,OAException.ERROR);

pageContext.putDialogMessage(message);

}

}

catch(OAException e)

{

System.out.println(e);

}

// Always close the iterator when you’re done.

rowsetiterator.closeRowSetIterator();

return counter+””;

}

 

 

Give comments about the post

Thank you for Reading

 

 

About pacesettergraam

A good and realistic person

Posted on August 28, 2013, in OAF and tagged , , , , , . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: