Follow by Email

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 click on that you want to insert row.
and call ViewObjectImpl createRow method to add new row in RowSet

I have created a method in AMImpl class and then 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 






 ViewObjectImpl demo1 = am.getEmployeesDemo1();
      Row r2 = demo1.createRow();         // Creates a row in ViewObject

      r2.setAttribute("EmployeeId", 001); // you can set all values

      demo1.insertRow(r2);                //Insert that row in ViewObject
      am.getDBTransaction().commit();     //Commit the changes, If you need
      demo1.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();


}