Home » Developer & Programmer » JDeveloper, Java & XML » add new multiple new rows (OAF)
add new multiple new rows [message #522658] Tue, 13 September 2011 01:50
ashokb21
Messages: 79
Registered: May 2010
Member
Hi all,
1. i am developing new OAF page in which i have call stored procedure in my AM but when add code for create additional row only single row is creating.when i click for another row nonew is created.

please help..

this is the code i have used in AM




--------------------------------------------------------------------------------

package EmployeeDetail.oracle.apps.fnd.EmployeeDetail.server;

import java.sql.CallableStatement;

import java.sql.SQLException;

import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.OAViewObject;
import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;
import oracle.apps.fnd.framework.server.OADBTransaction;
import oracle.apps.jtf.gantt.javaui.events.TaskIdEvent;

import oracle.jbo.Row;
//
--------------------------------------------------------------------------------
// --- File generated by Oracle ADF Business Components Design Time.
// --- Custom code may be added to this class.
// --- Warning: Do not modify method signatures of generated methods.
//
--------------------------------------------------------------------------------
public class EmployeeDetailAMImpl extends OAApplicationModuleImpl {
/**This is the default constructor (do not remove)
*/
public EmployeeDetailAMImpl() {
}


/**Sample main for debugging Business Components code using the tester.
*/
public static void main(String[] args) {
launchTester("EmployeeDetail.oracle.apps.fnd.EmployeeDetail.server", /* package name */
"EmployeeDetailAMLocal" /* Configuration Name */);
}

/**Container's getter for EmployeeDetailWIPVO1
*/
public EmployeeDetailWIPVOImpl getEmployeeDetailWIPVO1() {
return (EmployeeDetailWIPVOImpl)findViewObject("EmployeeDetailWIPVO1");
}
public void task(String Name)
{
OADBTransaction txn=getOADBTransaction();
CallableStatement cst=null;
OAViewObject vo=(OAViewObject)getEmployeeDetailWIPVO1();
try{
String CallProc="begin emp_task(:1);commit; end;";
cst=txn.createCallableStatement(CallProc,0);
cst.setString(1,Name);
cst.execute();
cst.close();


}
catch (SQLException sqle) {
throw OAException.wrapperException(sqle);
}


}


public void initDetail(String Name)
{
OAViewObject vo=(OAViewObject)getEmployeeDetailWIPVO1();
vo.setWhereClause(null);
vo.setWhereClauseParams(null);
vo.setWhereClause("TASK_ID=:1");
vo.setWhereClauseParam(0,Name);
vo.executeQuery();
}


public void createtask()
{
OAViewObject vo=(OAViewObject)getEmployeeDetailWIPVO1();
if(!vo.isPreparedForExecution())
{
vo.executeQuery();
}
Row row=vo.createRow();
vo.insertRow(row);
row.setNewRowState(Row.STATUS_INITIALIZED);


}



public void rowadd() {
OAViewObject vo = (OAViewObject)getEmployeeDetailWIPVO1();
OADBTransaction txn = getOADBTransaction();
if (!vo.isPreparedForExecution()) {
vo.setWhereClause("1=0");
vo.executeQuery();
}
Row row = vo.last();
row = vo.createRow();
vo.setCurrentRow(row);
vo.insertRow(row);
row.setNewRowState(Row.STATUS_INITIALIZED);
}
public void commit()
{
OADBTransaction txn=(OADBTransaction)getTransaction();
txn.commit();


}
public void rollback()
{
OADBTransaction txn=(OADBTransaction)getTransaction();
txn.rollback();
}


}




--------------------------------------------------------------------------------
this on COntroller


package EmployeeDetail.oracle.apps.fnd.EmployeeDetail.webui;

import java.io.Serializable;

import oracle.apps.fnd.common.VersionInfo;
import oracle.apps.fnd.framework.OAApplicationModule;
import oracle.apps.fnd.framework.webui.OAControllerImpl;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import oracle.apps.fnd.framework.webui.beans.table.OATableBean;

/**
* Controller for ...
*/
public class EmpTaskDetailCO extends OAControllerImpl
{
public static final String RCS_ID="$Header$";
public static final boolean RCS_ID_RECORDED =
VersionInfo.recordClassVersion(RCS_ID, "%packagename%");

/**
* Layout and page setup logic for a region.
* @param pageContext the current OA page context
* @param webBean the web bean corresponding to the region
*/
public void processRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processRequest(pageContext, webBean);


OATableBean tableBean =
(OATableBean)webBean.findChildRecursive("EmployeeDetailWIPVO11");
if (tableBean != null)
{
tableBean.setInsertable(true);
tableBean.setAutoInsertion(false);
}


}

/**
* Procedure to handle form submissions for form elements in
* a region.
* @param pageContext the current OA page context
* @param webBean the web bean corresponding to the region
*/
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processFormRequest(pageContext, webBean);
OAApplicationModule am=pageContext.getApplicationModule(webBean);
String Name=pageContext.getParameter("SRNO");
Serializable[] Nam={Name};
am.invokeMethod("createtask");
am.invokeMethod("task",Nam);
am.invokeMethod("initDetail",Nam);


/**if(pageContext.getParameter("CreateRow")!=null)
{
am.invokeMethod("rowadd");
}**/
OATableBean tableBean = (OATableBean)webBean.findChildRecursive("EmployeeDetailWIPVO11");
if (tableBean.getName().equals(pageContext.getParameter(SOURCE_PARAM)) &&
ADD_ROWS_EVENT.equals(pageContext.getParameter(EVENT_PARAM))) {
am.invokeMethod("rowadd");
}


else if (pageContext.getParameter("Apply")!=null)
{
am.invokeMethod("commit");
}


else if (pageContext.getParameter("Cancel")!=null)
{
am.invokeMethod("rollback");
}
}
}
Previous Topic: difference among gettransaction,getdbtransaction and getoadbtransaction
Next Topic: XML format for nested xmlelements
Goto Forum:
  


Current Time: Mon Apr 21 11:11:05 CDT 2014

Total time taken to generate the page: 0.21333 seconds