Pre-Requisite
Do complete the Search Page in OAF & Update Records in OAF.
Step 1: Custom
Properties for AM
Right click on SearchAM -> Edit SearchAM -> Custom Properties
Name RETENTION_LEVEL
Value MANAGE_STATE
Click add -> Apply -> OK
Step 2: Create
a Region & Button for Create Action
Select SearchPG.xml
Right Click on PageLayoutRN -> New -> Region
Update
the Properties
ID CreateRecordRN
Region Style pageButtonBar
Right Click on CreateRecordRN -> New -> Item
Update
the Properties
ID Create
Region Style submitButton
Attribute Set /oracle/apps/fnd/attributesets/Buttons/Create
Step 3: Create
a New Page for Insert Action
Name InsertPG
Package oracle.apps.fnd.searchproj.webui
Step 4: Create
a New Regions and Input Text Items
ID PageLayoutRN
Region Style pageLayout
AM Deifnition oracle.apps.fnd.searchproj.SearchAM
ID MainRN
Region Style messageComponentLayout
Right click on MainRN -> New -> messageTextInput
Update the Properties
ID
|
PersonType
|
Item
Style
|
messageTextInput
|
Maximum
Length
|
100
|
View
Instance
|
SearchVO
|
View
Attribute
|
PersonType
|
Prompt
|
PersonType
|
Length
|
20
|
ID
|
PersonName
|
Item
Style
|
messageTextInput
|
Maximum
Length
|
200
|
View
Instance
|
SearchVO
|
View
Attribute
|
PersonName
|
Prompt
|
PersonName
|
Length
|
20
|
ID
|
EmailAddresss
|
Item
Style
|
messageTextInput
|
Maximum
Length
|
100
|
View
Instance
|
SearchVO
|
View
Attribute
|
EmailAddresss
|
Prompt
|
EmailAddresss
|
Length
|
20
|
ID
|
ContactNumber
|
Item
Style
|
messageTextInput
|
Maximum
Length
|
100
|
View
Instance
|
SearchVO
|
View
Attribute
|
ContactNumber
|
Prompt
|
ContactNumber
|
Length
|
20
|
Step 5: Create
a New Region and Insert Action Buttons
Right click on PageLayoutRN -> New -> Region
Update the Properties
ID InsertPageButtonsRN
Region Style pageButtonBar
Create Apply and
Cancel Buttons for Insert Record Page
Right click on InsertPageButtonsRN -> New -> Item
Update the Properties
ID
|
Apply
|
Region
Style
|
submitButton
|
Attribute
Set
|
/oracle/apps/fnd/attributesets/Buttons/Apply
|
ID
|
Cancel
|
Region
Style
|
submitButton
|
Attribute
Set
|
/oracle/apps/fnd/attributesets/Buttons/Cancel
|
Step 6: Create
a New Controller for Insert Page
Right click on PageLayoutRN -> Set New Controller
Package Name oracle.apps.fnd.searchproj.webui
Class Name InsertCO
Step 7: Add the
below code in SearchAMImpl.java
import oracle.apps.fnd.framework.OAViewObject;
import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;
import oracle.apps.fnd.framework.server.OAViewObjectImpl;
import oracle.jbo.Row;
import oracle.apps.fnd.framework.OAViewObject;
public void createRecord()
{
OAViewObject vo = (OAViewObject)getSearchVO();
if (!vo.isPreparedForExecution())
{
vo.executeQuery();
}
Row row = vo.createRow();
vo.insertRow(row);
row.setNewRowState(Row.STATUS_INITIALIZED);
}
Step 8: Add the
below code in SearchCO.java
import oracle.apps.fnd.common.VersionInfo;
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.OAApplicationModule;
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;
import java.io.Serializable;
import oracle.apps.fnd.framework.OAApplicationModule;
Replace
the processRequest Code
public void processRequest(OAPageContext pageContext,OAWebBean
webBean)
{
super.processRequest(pageContext, webBean);
if (!pageContext.isFormSubmission())
{
OAApplicationModule am =
pageContext.getApplicationModule(webBean);
am.invokeMethod("createRecord", null);
}
}
Replace
the processFormRequest Code
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("SearchVO");
String PersonType =
(String)vo.getCurrentRow().getAttribute("PersonType");
String PersonName =
(String)vo.getCurrentRow().getAttribute("PersonName");
String EmailAddresss =
(String)vo.getCurrentRow().getAttribute("EmailAddresss");
String ContactNumber =
(String)vo.getCurrentRow().getAttribute("ContactNumber");
*/
OAException message = new OAException("Record has been
Inserted!", OAException.INFORMATION);
pageContext.putDialogMessage(message);
am.invokeMethod("apply");
pageContext.forwardImmediately(
"OA.jsp?page=/oracle/apps/fnd/searchproj/webui/SearchPG",
null, OAWebBeanConstants.KEEP_MENU_CONTEXT,
null,
null,
true, // retain AM
OAWebBeanConstants.ADD_BREAD_CRUMB_NO);
}
else if (pageContext.getParameter("Cancel") != null)
{
am.invokeMethod("rollback");
pageContext.forwardImmediately("OA.jsp?page=/oracle/apps/fnd/searchproj/webui/SearchPG",
null,
OAWebBeanConstants.KEEP_MENU_CONTEXT,
null,
null,
false, //
retain AM
OAWebBeanConstants.ADD_BREAD_CRUMB_NO);
}
}
Step 9: Save all
your work and Run SearchPG.xml
Step 10: Create
a New Record and Verify
Congratulations, you have
done it!
The search cannot be executed because the table has pending changes that would be lost.
ReplyDeletefacing the above error