Inserting Data into Database
DATA ENTRY PAGE IN OAF
For data entry
First create one workspace and project.
Create the AM.
Create the page and attach the AM to the main region of the page.
For Data Entry or any DML operation we need to create the Entity Object.
Steps to create the EO.
Right click on the project select new and then ADF Business Component And Entity Object.
Click ok, After that u will get the welcome window just click next.
In next window
Package :- Select your package from the list. And add the schema.server.
(sangu.oracle.apps.po.DataDisplayPRJ.schema.server)
Schema Object :- Select the table, view ,synonyms or materialized view on which u want to create the EO
Below that click the respective check box den only u will get them in the list.
Click next, next in step 3 of 5 if u want u can set the attributes like primary key etc.
Click next there u check in generate java all the check boxes as shown below.
Click next . In next if u want u can create the VO based on this EO directly.
Just give the VO name. then click next next and finish.
After creating the EO and VO u just attach this VO to AM.
Next come to the page and create one messageComponentLayout Region in that create the items for which u want to insert the data.
And create two submitButtons for saving the data and clearing the data.
Now set the following properties for each item except submitButton
View Instance:- Select the view instance from the lov
View Attribute:- Select the attribute u want, from the lov.
And set the proper data type and prompt for each item.
If u want the space between the buttons then create one item set the style as spacer
And set the property.
Width: Give some distance (20)
After completing the page structure now write the following code in the java file of the AM.
Select the AM in structure it will show the DataDisplayAMImpl.java just double click on that.
U will get the window.
In that java file create one method for inserting the data.
/*for copy paste*/
public void insertData()
{
/*Write the following code to initialize the VO*/
OAViewObject vo = getFwkTbxEmployeesEOVO1();
if(!vo.isPreparedForExecution())
{
vo.executeQuery();
}
/*write the following code to create one empty row */
OARow row=(OARow)vo.createRow();
/*write the following to isert the data*/
vo.insertRow(row);
}
Create another method for saving the data.
/*for copy paste*/
public void Save()
{
getOADBTransaction().commit();
}
After creating the methods in AM java file create one controller and call these methods in that.
Write the following code in processRequest of the controller.
/*for copy paste*/
public void processRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processRequest(pageContext, webBean);
/*for initializing the AM */
OAApplicationModule am=(OAApplicationModule)pageContext.getRootApplicationModule();
/*invoke the method which u write for inserting data */
am.invokeMethod("insertData");
}
Write the following in the processFormRequest of the controller.
/*for copy paste*/
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processFormRequest(pageContext, webBean);
/*for initializing the AM */
OAApplicationModule am=(OAApplicationModule)pageContext.getRootApplicationModule();
if(pageContext.getParameter("Save")!=null)
{
/*invoke the method which u write for saving the data */
am.invokeMethod("Save");
/* for throwing confirmation message*/
throw new OAException("Data Entered Successfully”,
OAException.CONFIRMATION);
}
}
Run the page to get the output.
After clicking the Clear button if u want to clear the fields write the following code in processFormRequest.
/*for copy paste*/
if(pageContext.getParameter("Clear")!=null)
{
OAMessageTextInputBean msb1 = (OAMessageTextInputBean)webBean.findChildRecursive("EmployeeId");
msb1.setValue(pageContext,null);
OAMessageTextInputBean msb2 = (OAMessageTextInputBean)webBean.findChildRecursive("Title");
msb2.setValue(pageContext,null);
OAMessageTextInputBean msb3 = (OAMessageTextInputBean)webBean.findChildRecursive("FirstName");
msb3.setValue(pageContext,null);
OAMessageTextInputBean msb4 = (OAMessageTextInputBean)webBean.findChildRecursive("LastName");
msb4.setValue(pageContext,null);
OAMessageTextInputBean msb5 = (OAMessageTextInputBean)webBean.findChildRecursive("PositionCode");
msb5.setValue(pageContext,null);
OAMessageTextInputBean msb6 = (OAMessageTextInputBean)webBean.findChildRecursive("Salary");
msb6.setValue(pageContext,null);
}
For data entry
First create one workspace and project.
Create the AM.
Create the page and attach the AM to the main region of the page.
For Data Entry or any DML operation we need to create the Entity Object.
Steps to create the EO.
Right click on the project select new and then ADF Business Component And Entity Object.
Click ok, After that u will get the welcome window just click next.
In next window
Package :- Select your package from the list. And add the schema.server.
(sangu.oracle.apps.po.DataDisplayPRJ.schema.server)
Schema Object :- Select the table, view ,synonyms or materialized view on which u want to create the EO
Below that click the respective check box den only u will get them in the list.
Click next, next in step 3 of 5 if u want u can set the attributes like primary key etc.
Click next there u check in generate java all the check boxes as shown below.
Click next . In next if u want u can create the VO based on this EO directly.
Just give the VO name. then click next next and finish.
After creating the EO and VO u just attach this VO to AM.
Next come to the page and create one messageComponentLayout Region in that create the items for which u want to insert the data.
And create two submitButtons for saving the data and clearing the data.
Now set the following properties for each item except submitButton
View Instance:- Select the view instance from the lov
View Attribute:- Select the attribute u want, from the lov.
And set the proper data type and prompt for each item.
If u want the space between the buttons then create one item set the style as spacer
And set the property.
Width: Give some distance (20)
After completing the page structure now write the following code in the java file of the AM.
Select the AM in structure it will show the DataDisplayAMImpl.java just double click on that.
U will get the window.
In that java file create one method for inserting the data.
/*for copy paste*/
public void insertData()
{
/*Write the following code to initialize the VO*/
OAViewObject vo = getFwkTbxEmployeesEOVO1();
if(!vo.isPreparedForExecution())
{
vo.executeQuery();
}
/*write the following code to create one empty row */
OARow row=(OARow)vo.createRow();
/*write the following to isert the data*/
vo.insertRow(row);
}
Create another method for saving the data.
/*for copy paste*/
public void Save()
{
getOADBTransaction().commit();
}
After creating the methods in AM java file create one controller and call these methods in that.
Write the following code in processRequest of the controller.
/*for copy paste*/
public void processRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processRequest(pageContext, webBean);
/*for initializing the AM */
OAApplicationModule am=(OAApplicationModule)pageContext.getRootApplicationModule();
/*invoke the method which u write for inserting data */
am.invokeMethod("insertData");
}
Write the following in the processFormRequest of the controller.
/*for copy paste*/
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processFormRequest(pageContext, webBean);
/*for initializing the AM */
OAApplicationModule am=(OAApplicationModule)pageContext.getRootApplicationModule();
if(pageContext.getParameter("Save")!=null)
{
/*invoke the method which u write for saving the data */
am.invokeMethod("Save");
/* for throwing confirmation message*/
throw new OAException("Data Entered Successfully”,
OAException.CONFIRMATION);
}
}
Run the page to get the output.
After clicking the Clear button if u want to clear the fields write the following code in processFormRequest.
/*for copy paste*/
if(pageContext.getParameter("Clear")!=null)
{
OAMessageTextInputBean msb1 = (OAMessageTextInputBean)webBean.findChildRecursive("EmployeeId");
msb1.setValue(pageContext,null);
OAMessageTextInputBean msb2 = (OAMessageTextInputBean)webBean.findChildRecursive("Title");
msb2.setValue(pageContext,null);
OAMessageTextInputBean msb3 = (OAMessageTextInputBean)webBean.findChildRecursive("FirstName");
msb3.setValue(pageContext,null);
OAMessageTextInputBean msb4 = (OAMessageTextInputBean)webBean.findChildRecursive("LastName");
msb4.setValue(pageContext,null);
OAMessageTextInputBean msb5 = (OAMessageTextInputBean)webBean.findChildRecursive("PositionCode");
msb5.setValue(pageContext,null);
OAMessageTextInputBean msb6 = (OAMessageTextInputBean)webBean.findChildRecursive("Salary");
msb6.setValue(pageContext,null);
}
No comments:
Post a Comment