Code in Controller
==============
public void processRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processRequest(pageContext, webBean);
OAApplicationModule am=pageContext.getApplicationModule(webBean);
am.invokeMethod("CreateSupplierRow");
}
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processFormRequest(pageContext, webBean);
OAApplicationModule am=pageContext.getApplicationModule(webBean);
String event =pageContext.getParameter(OAWebBeanConstants.EVENT_PARAM);
String source =pageContext.getParameter(OAWebBeanConstants.SOURCE_PARAM);
if(pageContext.getParameter("Apply")!=null)
{
am.invokeMethod("SaveData");
//These five lines are to display the confirmation message..
String supId =pageContext.getParameter("SuppNumber");
String supName =pageContext.getParameter("SuppName");
MessageToken[] tokens = {new MessageToken("SUPID",supId),new MessageToken("SNAME",supName)};
OAException msg = new OAException("PO","SUPPLIER_SAVED_MSG",tokens,OAException.CONFIRMATION,null);
throw msg;
}
if(ADD_ROWS_EVENT.equals(event))
{
am.invokeMethod("CreateSitesRow");
}
}
}
Code in the AM
==============
public void CreateSupplierRow()
{
SuppliersEOVOImpl vo=getSuppliersEOVO1();
Row row=vo.createRow();
if(!vo.isPreparedForExecution())
{
vo.setMaxFetchSize(0);
}
vo.insertRow(row);
//we need to import import oracle.jbo.domain.Number
//Setting the sequence value to the Supplier ID attribute(field)
Number seq =getOADBTransaction().getSequenceValue("fwk_tbx_suppliers_s");
row.setAttribute("SupplierId",seq);
row.setNewRowState(Row.STATUS_INITIALIZED);
}
public void CreateSitesRow()
{
SitesEOVOImpl vo=getSitesEOVO1();
SuppliersEOVOImpl vo1=getSuppliersEOVO1();
Row siterow=vo.createRow();
if(!vo.isPreparedForExecution())
{
vo.setMaxFetchSize(0);
}
int count =vo.getRowCount();
vo.insertRowAtRangeIndex(count,siterow);
//Setting the sequence values in SupplierID,SuppliersiteID Attributes(fields).
Number seq =getOADBTransaction().getSequenceValue("fwk_tbx_supplier_sites_s");
String mSupId =vo1.getCurrentRow().getAttribute("SupplierId").toString();
siterow.setAttribute("SupplierId",mSupId); //Setting the sequence value in SupplierID attribute
siterow.setAttribute("SupplierSiteId",seq); //Setting the sequence value in SupplierSiteId Attribute
siterow.setAttribute("SerialNum",count+1); //Setting the sequence value in SerialNum Transient Attribute.
siterow.setNewRowState(Row.STATUS_INITIALIZED);
}
//Written by Shashi..
public void SaveData()
{
this.getTransaction().commit();
}
}
0 comments:
Post a Comment