Friday, December 21, 2018

Steps to Apply OD in JNTU Kakinada

https://www.jntukexams.net/online1/apply_online.php

https://www.youtube.com/watch?v=KMyZMVIfDTE

1. We need to Register first to apply OD.




2. After Register we need to Login using login option.





3. We need to do all below steps to complete .
In each step we have to follow instructions .
Note : Here I have taken screen shot after I completed all process.

Sunday, June 3, 2018

Base classes for ADF Business Components

Custom base classes are used to customize functionalities of business component objects and to write reusable code in application. We must configure base classes before creating business components like Application Module, Entity, View Object and etc.

For Configure business components Right Click on the Model project and go to Project Properties and expand Business Components and click on Base classes. Sometimes Browse button will not appear, at that time we need to add the connection to the application through New --> ADF Business components ---> Business Components from tables --> add connection and click finish, it will create Model.jpx file(Don't create any EO, VO or AM).




















Custom ApplicationModuleImpl :
import oracle.jbo.server.ApplicationModuleImpl;

public class FMWAppModuleImpl extends ApplicationModuleImpl {
    public FMWAppModuleImpl() {
        super();
    }
}

Custom EntityImpl :
import oracle.jbo.server.EntityImpl;

public class FMWEOImpl extends EntityImpl {
    public FMWEOImpl() {
        super();
    }
}

Custom ViewObjectImpl :
import oracle.jbo.server.ViewObjectImpl;

public class FMWVOImpl extends ViewObjectImpl {
    public FMWVOImpl() {
        super();
    }
}

Custom ViewRowImpl :
import oracle.jbo.server.ViewRowImpl;

public class FMWVORowImpl extends ViewRowImpl {
    public FMWVORowImpl() {
        super();
    }
}

Why Custom Base classes :
It is a good practice to configure custom base classes to ADF application.  Custom base classes simplify the reusable code. In below code works as contains instead of start string in table string filter.

public class FMWVOImpl extends ViewObjectImpl {
    public FMWVOImpl() {
        super();
    }
    /**
      * For filter works like contains
    **/
     public String getCriteriaItemClause(ViewCriteriaItem viewCriteriaItem) {
         if (viewCriteriaItem.getAttributeDef().getJavaType().getName().equals("java.lang.String")) {
             if (!(viewCriteriaItem.getValue() != null && viewCriteriaItem.getValue().toString().startsWith(":")))
                 viewCriteriaItem.setValue("%" + viewCriteriaItem.getValue() + "%");

         }
         viewCriteriaItem.setUpperColumns(true);
         return super.getCriteriaItemClause(viewCriteriaItem);

     }
}

For using this functionality we just need to generate a class for view object which we are using in af:table data.




Tuesday, January 27, 2015

ADF: Inserting data into parent table and using parent id insert data into child table in ADF.

Step 1 :

Create a sequence .

CREATE SEQUENCE id_seq
  start with 1
  increment by 1;

Step 2 :

Create EO and VO using database table.Edit Entity Object id and select value type as expression and put the bellow value.

(new racle.jbo.server.SequenceImpl("id_seq",adf.object.getDBTransaction())).getSequenceNumber().

Step 3 :

Create form using view object in datacontrols in jsf page and add createInsert,commit,rollback actions bindings to page.
In save button action listener write bellow code

         DCBindingContainer bindings =
            (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
   //     int id =((BigDecimal)JSFUtils.resolveExpression("#{bindings.Id.inputValue}")).intValue();
  int id =((Number)JSFUtils.resolveExpression("#{bindings.Id.inputValue}")).intValue();
        DCIteratorBinding roleIter =
            bindings.findIteratorBinding("EmpVO1Iterator");
        ViewObject obj = roleIter.getViewObject();
             Row newRow = obj.createRow();
             newRow.setNewRowState(Row.STATUS_INITIALIZED);
            newRow.setAttribute("deptId", id);
            newRow.setAttribute("EmpId", "some value");

            obj.insertRow(newRow);
        }
         executeMethodBinding("Commit");

Note :

If any one got bellow exception change datatype of ID number to Bigdecimal in EO
java.lang.ArrayIndexOutOfBoundsException: 1 at oracle.sql.NUMBER.toBigDecimal(NUMBER.java:681).




Friday, September 21, 2012

Java code for converting Excel file into XML file

package adf;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

import java.util.Iterator;


import java.util.logging.Level;
import java.util.logging.Logger;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;

public class Excel_To_Xml {
   public Excel_To_Xml() {
    super();
  }

  public static void main(String[] args) {

        Excel_To_Xml xml = new Excel_To_Xml();
     
      String filename = "file path";  //Ex:D:/sample.xsl
     xml.readAndConvertToXML(filename);
            
    }
public String readAndConvertToXML(String filepath) {

    FileInputStream fis = null;
    String out =
      "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n";

    try {

      fis = new FileInputStream(filepath);
      HSSFWorkbook workbook = new HSSFWorkbook(fis);
      HSSFSheet sheet = workbook.getSheetAt(0);
      Iterator rows = sheet.rowIterator();

      System.out.println(logger.getName());
      int j = 0;

      int k = 0;
      out += "<records>\n";
      while (rows.hasNext()) {

        HSSFRow row = (HSSFRow)rows.next();
        k = row.getPhysicalNumberOfCells();
      
        Iterator cells = row.cellIterator();
        System.out.println(k);
        String arr[] =
        { "a", "b", "c", "d", "e", "f" };
        int ca = 0, cb = 0;
        out += "\t<record>\n";
       
        for (j = 1; j <=k; j++) {
          cb = (j) % 6;
          ca = (j) / 6;
          String node = "";
          if (ca == 0)
            node = arr[cb - 1];
          else
            node = arr[ca - 1] + "" + arr[cb];
         
          out +=
              "\t\t<" + node + ">" + row.getCell(j - 1,Row.CREATE_NULL_AS_BLANK).toString() +
              "<\\" + node + ">\n";
        }
        out += "\t<\\record>\n";
     
      }
      out += "<\\records>";
      System.out.println(out);

    } catch (Exception e) {
      logger.log(Level.SEVERE, "File not uploaded"); //e.printStackTrace();
    }
    logger.fine("done");
    return out;
  }
  }