Please disable your adblock and script blockers to view this page

Search this blog

Tuesday, 11 December 2012

Insert New Row in ADF ViewObject Programatically

Here I am showing how to insert new row in ADF view object programmatically.

For this create a method in managed bean for your button on that you want to insert row.
and call this AMImpl method that makes use of ViewObjectImpl createRow method to add new row in RowSet

Created a method in AMImpl class and it'll be called in managed bean using binding layer

This method creates a row in ViewObject , and you can set(Insert) this row with some values using this simple snippet of code 







//Get ViewObject Instance
    ViewObjectImpl demoVo = this.getEmployeesDemo1();


// Creates a row in ViewObject
    Row r = demoVo.createRow();  
      
// You can set attribute values in this new row
    r.setAttribute("EmployeeId", 001); 

//Insert that row in ViewObject
    demoVo.insertRow(r);   
             
//Commit the changes, If you need
    this.getDBTransaction().commit();     
    demoVo.executeQuery();

This is how you can create row in ViewObject


Wednesday, 5 December 2012

Datatype conversion in Java (Typecasting)



How to do basic data type conversion in Java


  •     Convert Integer to String
  •     BigDecimal to Integer
  •     Integer to BigDecimal
  •     Double to Integer
  •     Integer to double





package practiceJava;

import java.math.BigDecimal;

public class TypeConversion {
    public static void main(String[] args) {
        /*Convert String to Integer*/
        String name = "1234";
        Integer nm = Integer.parseInt(name);
        System.out.println("Name in Integer-->" + nm);
    }


    /*Convert Integer to String*/

    Integer a = 23;
    String num = a.toString();
    /*BigDecimal to Integer*/
    BigDecimal nom = new BigDecimal(450.9);
    Integer nomInt = nom.intValue();

    /*Integer to BigDecimal*/

    Integer cm = 45;
    BigDecimal cmBd = new BigDecimal(cm);
    
    /*Double to Integer*/

    double sys = 3;
    Integer sysInt = new Integer((int)sys);
   
   /*Integer to double*/
    Integer sd = 456;
    double sdDb = sd.doubleValue();


}

Thursday, 29 November 2012

Add Serial No. in Table in ADF, Auto Increment column in ADF table

ADF provides easy way to add a autoincrement column in table to make Serial No. or Sequence Column for table ,thats value autoincrements with no.of rows in table .
You have to follow these steps to do this.

  • Go to tabel properties (property Inspector) and set VarStatus to vs

set varStatus of af:table to vs
  •  Now add a column in table and drop an output text inside this new added column
Add new column to af:table to show serial number for each row
  • Select output text and Go to its property inspector and set value to #{vs.index+1} as it is selected in Expression Builder by going through- 
ExpressionBuilder----->JspObjects--->VS---->index




using varStatus we can access various built in function like index,count etc
  • You have done now run your page and you can see a serial no. column
af:table with serial number column