1- To display the any message alongwith data of some field. Like Hello! (Field Data).
Edit Your Controller and add the following line alongwith imports.
import oracle.apps.fnd.framework.OAException;
Add Following Code in processFormRequest (Red Colored.
public void initQuery(String Column1, String Column2)
{
if ((Column1 != null) && (!("".equals(Column1.trim()))))
{
setWhereClause("column1 = :1 AND column2 = :2");
setWhereClauseParams(null); // Always reset
setWhereClauseParam(0, Column1);
setWhereClauseParam(1, Column2);
executeQuery();
}
}
******************************************************************************************************
Edit Your Controller and add the following line alongwith imports.
import oracle.apps.fnd.framework.OAException;
Add Following Code in processFormRequest (Red Colored.
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processFormRequest(pageContext, webBean);
if (pageContext.getParameter("Go") != null)
{
String userContent = pageContext.getParameter("Field Name");
String message = "Hello, " + userContent + "!";
throw new OAException(message, OAException.INFORMATION);
}
}
******************************************************************************************************
2- Coding during creation of data entry form
A- Add createRecord method to your InsertAMImpl classimport oracle.jbo.Row; import oracle.apps.fnd.framework.OAViewObject; ... public void createRecord() { OAViewObject vo = (OAViewObject)getInsertVO1(); if (!vo.isPreparedForExecution()) { vo.executeQuery(); } Row row = vo.createRow(); vo.insertRow(row); row.setNewRowState(Row.STATUS_INITIALIZED); }
B- Add Create Page Initialization to your Controller
Add following code to your processRequest()import oracle.apps.fnd.framework.OAApplicationModule; ... public void processRequest(OAPageContext pageContext,OAWebBean webBean) { super.processRequest(pageContext, webBean); if (!pageContext.isFormSubmission()) { OAApplicationModule am = pageContext.getApplicationModule(webBean); am.invokeMethod("createRecord", null); } }
C- Add below method in InsertAMImpl Class to handle Apply Button actionimport oracle.jbo.Transaction; ... public void apply() { getTransaction().commit(); }
D- Add below Logic in InsertCO to handle Apply Button
Add following code to your processFormRequest()
import oracle.jbo.domain.Number;
import oracle.apps.fnd.common.MessageToken;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.OAViewObject;
import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
...
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{super.processFormRequest(pageContext, webBean); OAApplicationModule am = pageContext.getApplicationModule(webBean);
// Pressing the "Apply" button means the transaction should be
// validated and committed.
if (pageContext.getParameter("Apply") != null)
{
OAViewObject vo = (OAViewObject)am.findViewObject("InsertVO1");
String column1 = (String)vo.getCurrentRow().getAttribute("Column1"); String column2 = (String)vo.getCurrentRow().getAttribute("Column2"); am.invokeMethod("apply"); // Create a FND Message with name "TEST_CREATE_CONFIRM" with two // tokens MessageToken[] tokens = { new MessageToken("COLUMN1", column1), new MessageToken("COLUMN2", column2) }; OAException confirmMessage = new OAException( "FND", "TEST_CREATE_CONFIRM", tokens, OAException.CONFIRMATION, null); pageContext.putDialogMessage(confirmMessage); pageContext.forwardImmediately( "OA.jsp?page=/Testpage/oracle/apps/fnd/insertdemo/webui/InsertPG", null, OAWebBeanConstants.KEEP_MENU_CONTEXT, null, null, true, // retain AM OAWebBeanConstants.ADD_BREAD_CRUMB_NO);
}
}
******************************************************************************************************
3 - Coding in Update form
A - Add Following code in Search Page controller SearchCO
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
import oracle.apps.fnd.framework.webui.beans.layout.OAQueryBean;
public void processRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processRequest(pageContext, webBean);
OAQueryBean queryBean = (OAQueryBean)webBean.findChildRecursive("QueryRN");
queryBean.clearSearchPersistenceCache(pageContext);
}
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processFormRequest(pageContext, webBean);
if ("update".equals(pageContext.getParameter(EVENT_PARAM)))
{
pageContext.setForwardURL("OA.jsp?page=/UpdatePage/oracle/apps/fnd/searchdemo/webui/UpdatePG",
null,
OAWebBeanConstants.KEEP_MENU_CONTEXT,
null,
null,
true,
OAWebBeanConstants.ADD_BREAD_CRUMB_NO,
OAWebBeanConstants.IGNORE_MESSAGES);
}
}
B - Add Following code in Update Page controller UpdateCO
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
import oracle.apps.fnd.framework.OAApplicationModule;
import java.io.Serializable;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
import oracle.apps.fnd.framework.OAApplicationModule;
import java.io.Serializable;
public void processRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processRequest(pageContext, webBean);
OAApplicationModule am = pageContext.getApplicationModule(webBean);
{
super.processRequest(pageContext, webBean);
OAApplicationModule am = pageContext.getApplicationModule(webBean);
String Column1 = pageContext.getParameter("PColumn1");
String Column2 = pageContext.getParameter("PColumn2");
Serializable[] params = { Column1, Column2 };
am.invokeMethod("updateRow", params);
}
String Column2 = pageContext.getParameter("PColumn2");
Serializable[] params = { Column1, Column2 };
am.invokeMethod("updateRow", params);
}
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processFormRequest(pageContext, webBean);
OAApplicationModule am = pageContext.getApplicationModule(webBean);
if (pageContext.getParameter("Apply") != null)
{
am.invokeMethod("apply");
pageContext.forwardImmediately("OA.jsp?page=/UpdatePage/oracle/apps/fnd/searchdemo/webui/SearchPG",
null,
OAWebBeanConstants.KEEP_MENU_CONTEXT,
null,
null,
false, // retain AM
OAWebBeanConstants.ADD_BREAD_CRUMB_NO);
}
else if (pageContext.getParameter("Cancel") != null)
{
am.invokeMethod("rollback");
pageContext.forwardImmediately("OA.jsp?page=/UpdatePage/oracle/apps/fnd/searchdemo/webui/SearchPG",
null,
OAWebBeanConstants.KEEP_MENU_CONTEXT,
null,
null,
false, // retain AM
OAWebBeanConstants.ADD_BREAD_CRUMB_NO);
}
}
{
super.processFormRequest(pageContext, webBean);
OAApplicationModule am = pageContext.getApplicationModule(webBean);
if (pageContext.getParameter("Apply") != null)
{
am.invokeMethod("apply");
pageContext.forwardImmediately("OA.jsp?page=/UpdatePage/oracle/apps/fnd/searchdemo/webui/SearchPG",
null,
OAWebBeanConstants.KEEP_MENU_CONTEXT,
null,
null,
false, // retain AM
OAWebBeanConstants.ADD_BREAD_CRUMB_NO);
}
else if (pageContext.getParameter("Cancel") != null)
{
am.invokeMethod("rollback");
pageContext.forwardImmediately("OA.jsp?page=/UpdatePage/oracle/apps/fnd/searchdemo/webui/SearchPG",
null,
OAWebBeanConstants.KEEP_MENU_CONTEXT,
null,
null,
false, // retain AM
OAWebBeanConstants.ADD_BREAD_CRUMB_NO);
}
}
C - Add following Code in SearchAMImpl
import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;
import oracle.apps.fnd.framework.server.OAViewObjectImpl;
public void updateRow(String Column1, String Column2)
{
SearchVOImpl vo = (SearchVOImpl)getSearchVO1();
vo.initQuery(Column1, Column2);
}
public void apply()
{
getTransaction().commit();
}
public void updateRow(String Column1, String Column2)
{
SearchVOImpl vo = (SearchVOImpl)getSearchVO1();
vo.initQuery(Column1, Column2);
}
public void apply()
{
getTransaction().commit();
}
public void rollback()
{
getTransaction().rollback();
}
{
getTransaction().rollback();
}
D - Add following Code in SearchVOImpl
import oracle.apps.fnd.framework.server.OAViewObjectImpl;
public void initQuery(String Column1, String Column2)
{
if ((Column1 != null) && (!("".equals(Column1.trim()))))
{
setWhereClause("column1 = :1 AND column2 = :2");
setWhereClauseParams(null); // Always reset
setWhereClauseParam(0, Column1);
setWhereClauseParam(1, Column2);
executeQuery();
}
}
******************************************************************************************************
4 - Coding on Delete Form
A - Add deleteRecord() method to MatloobSearchAMImpl
import oracle.apps.fnd.framework.OAViewObject;
import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;
import oracle.jbo.domain.Number;
import oracle.apps.fnd.framework.server.OAViewObjectImpl;
import oracle.jbo.RowSetIterator;
public void deleteRecord(String Column1)
{ OAViewObject vo = (OAViewObject)getMatloobSearchVO1();
SearchVORowImpl row = null;
int fetchedRowCount = vo.getFetchedRowCount();
RowSetIterator deleteIter = vo.createRowSetIterator("deleteIter");
if (fetchedRowCount > 0)
{ deleteIter.setRangeStart(0);
deleteIter.setRangeSize(fetchedRowCount);
for (int i = 0; i < fetchedRowCount; i++)
{
row = (SearchVORowImpl)deleteIter.getRowAtRangeIndex(i);
row.remove();
getTransaction().commit();
break;
}
}
deleteIter.closeRowSetIterator();
} // end deleteRecord
B - Add DeleteSelection Handler Code to MatloobSearchCO.processFormRequest()
import com.sun.java.util.collections.HashMap;
import oracle.apps.fnd.framework.webui.OADialogPage;
import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
import oracle.apps.fnd.common.MessageToken;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
import oracle.apps.fnd.framework.OARow;
import oracle.apps.fnd.framework.OAApplicationModule;
...
OAApplicationModule am = pageContext.getApplicationModule(webBean);
OAViewObject vo =(OAViewObject)am.findViewObject("MatloobSearchVO1");
String rowRef =
pageContext.getParameter(OAWebBeanConstants.EVENT_SOURCE_ROW_REFERENCE);
OARow row = (OARow)am.findRowByRef(rowRef);
if ("delete".equals(pageContext.getParameter(EVENT_PARAM)))
{
String Column1 = (String)row.getAttribute("Column1");
String Column2 = (String)row.getAttribute("Column2");
String Column3 = pageContext.getParameter("Column1");
String Column4 = pageContext.getParameter("Column2");
MessageToken[] tokens = { new MessageToken("COLUMN1", Column1),
new MessageToken("COLUMN2", Column2)};
OAException mainMessage = new OAException("FND",
"DELETE_RECORD_WARN", tokens);
OADialogPage dialogPage = new OADialogPage(OAException.WARNING,
mainMessage, null, "", "");
String yes = pageContext.getMessage("AK", "FWK_TBX_T_YES", null);
String no = pageContext.getMessage("AK", "FWK_TBX_T_NO", null);
dialogPage.setOkButtonItemName("DeleteYesButton");
dialogPage.setOkButtonToPost(true);
dialogPage.setNoButtonToPost(true);
dialogPage.setPostToCallingPage(true);
dialogPage.setOkButtonLabel(yes);
dialogPage.setNoButtonLabel(no);
java.util.Hashtable formParams = new java.util.Hashtable(1);
formParams.put("Column1", Column3);
formParams.put("Column2", Column4);
dialogPage.setFormParameters(formParams);
pageContext.redirectToDialogPage(dialogPage);
}
C - Add Delete Confirmation Handler Code to MatloobSearchCO.processFormRequest()
import java.io.Serializable;
import oracle.apps.fnd.framework.OAApplicationModule;
...
else if (pageContext.getParameter("DeleteYesButton") != null)
{
String Column1 = pageContext.getParameter("Column1");
String Column2 = pageContext.getParameter("Column2");
Serializable[] parameters = { Column1 };
OAApplicationModule am =
pageContext.getApplicationModule(webBean);
am.invokeMethod("deleteRecord", parameters);
OAException message = new OAException("FND",
"DELETE_CONFIRM", null,
OAException.CONFIRMATION, null);
pageContext.putDialogMessage(message);
}
******************************************************************************************************
This comment has been removed by the author.
ReplyDeleteHi Followed the same approach. But it is redirecting to processrequest and failing.
ReplyDelete