In this tutorial, we will see how a new record can be added to a table using OA Framework screen.
We shall continue from where we left in the previous tutorial.
For simplicity
CO Controller class. A java class attached to the page/region within a page.
PFR processFormRequest [a method in controller class that is invoked when an action takes place in screen, just like good old triggers in D2K]
PR processRequest [a method in controller class that is invoked when a page loads in the browser]
Lets say the business requirement is
1. Add a button labelled "Create Person"
2. When this button is clicked, then processFormRequest(PFR) of the controller will be called in the main page [ie. xxPersonMainPG].
3. From the PFR of CO, call another screen named managePerson, by retaining the AM. managePersonPG screen will have one single record using which we will facilitate both updates and inserts to person table. (this is your design approach, I have chosen to use the same screen[managePersonPG] for both inserts and updates to person table).
This example is about inserts into the person table.
4. The navigation now moves to managePersonPG screen, and the Controller method processRequest() of managePersonPG screen will now be called.
(Note:- remember that processRequest is called as soon as the page is about to be rendered in browser)
5. In processRequest of managePersonPG screen, we will initialize a blank record, so that fresh inserts can be done.
6. On managePersonPG screen, a button named "Commit Data" will be available.
7. After entering data into the fields/record, user will click "Commit Data", hence invoking processFormRequest of the controller inmanagePersonPG.
From processFormRequest, we will invoke a method in AM, that will commit the transaction. Name of this method in CO is savePersonToDatabase()
8. After doing commit, we navigate back to the mainPage, i.e. back to xxPersonMainPG using pageContext.setForwardURL
Why do we need Step 5?
Answer:- Here we have fields in screen that map to columns within view object. When data is entered in these fields, these will then get transferred into view object record(in memory), when form is submitted. Hence for this purpose, we need to create a blank record in VO[view object], by callingvo.createRow, so that user can enter data into that row.
When a commit takes place; how does OA Framework know whether an insert or update must be done?
In this case we are setting the status of the record to STATUS_INITIALIZED. Once a commit takes place, Framework will then internally change the status of the row to update.
I want to default value into personid field from a database sequence. How do I do that?
One way of doing this is by defaulting a value at the time of blank record being created in VO. vo.createRow will call create() method in Entity Object. This is equivalent of when-create-record trigger in D2K.
What are the steps in tutorial?
1. Create a button on the main page, to "Add new Person". This button when clicked will raise an event named createPerson.
This event can then be trapped in PFR of the controller.
Click here for Video Link [creating this button and raising event]
2. In the mainPage's CO, inside PFR, handle the click of button "create new Person".
Call managePerson page, passing it parameter named xxParamActionOnPerson=createPerson
Click here for a demonstration of this step
3. Build a managePersonPG OA page using jDeveloper. This page will present user with a record to enter a new person.
Also add a button "Commit Data" to this page.
Click here for video link
4. Set a new controller for the new page xxManagePersonPG
In PR(processRequest) of the CO for xxManagePersonPG, call an AM method to initialize record(provided action is createRecord). Remember that processRequest is called when the page loads.In the corresponding AM method, initialize the record.
Click here for video link
6. Final step to handle a commit on managePersonPG, and to redirect the user back to the original main page[xxPersonMainPG ], after the new person has been created[after commit].
Test this (complete missing step to generate sequence)
Click here to see the last step of this tutorial
Comments
Thank you very much for taking out sometime from your busy schedule and
providing us with this tutorial.
I can create person in JDeveloper but after I had deployed it in Apps environment,whe n I click on CreatePerson it shows the Search page instead of ManagePerson page.
I've moved all the class files in binary mode and others in Ascii mode
in apps environmentwith with same folder structure.
Plea se give some solution.
Did you import both the pages into MDS, i.e. main page and manage person page?
Thanks,
Anil
where do we write business logic in OAframework.
r egards
ram
I have a problem, when i click the create button the fields is not displayed,
and an error occurs, please help.
oracle.a pps.fnd.framewo rk.OAException: No data found for region (/oracle/apps/a k/xxperson/webu i/xxPersonMainP G).
oracle.ad f.mds.MetadataD efException: Unable to find component with absolute reference = /oracle/apps/ak /xxperson/webui /xxPersonMainPG , XML Path = C:\software\AOJ DeveloperSoft\j devhome\jdev\my classes\JRADXML ;C:\software\AO JDeveloperSoft\ jdevhome\jdev\m yprojects;C:\so ftware\AOJDevel operSoft\jdevbi n\jdev\oamdsxml wk. Please verify that the reference is valid and the definition of the component exists either on the File System or in the MDS Repository.
or acle.adf.mds.Me tadataDefExcept ion: Unable to find component with absolute reference = /oracle/apps/ak /xxperson/webui /xxPersonMainPG , XML Path = C:\software\AOJ DeveloperSoft\j devhome\jdev\my classes\JRADXML ;C:\software\AO JDeveloperSoft\ jdevhome\jdev\m yprojects;C:\so ftware\AOJDevel operSoft\jdevbi n\jdev\oamdsxml wk. Please verify that the reference is valid and the definition of the component exists either on the File System or in the MDS Repository.
Great Tutorial on OA Framework. I really liked it. I have a small problem in the CreatePersonMet hod in the PersonAM. The if condition is failing.
publi c void createPersonMet hod (String pAction, String pPersonId)
{
OAViewObjectImp l pervo =getPersonDetai lsVO1();
System.out.prin tln("========== ========in PersonAM CreatePersonMet hod");
if (! pervo.isPrepare dForExecution() )
{
System.out.prin tln("inside createPersonMet hod");
pervo.executeQu ery();
Row prow = pervo.createRow ();
pervo.insertRow (prow);
prow.setNewRowS tate(Row.STATUS _INITIALIZED);
}
else
{
System.out.prin tln("not in CreatePersonMet hod");
}
}
if I remove the "!" from the if condition it works fine. Please advise.
Apprec iate your help.
Thanks and regards.
Siva
I have developed a jsp for insertion and updation put when the controller redirects control to next page and i want to insert a new record or update it it shows no current row for view.
we earlier developed jsp following ur tips. But now i have more complexities to address:
Plz provide some clarifications regarding:
1.How do we write update/create method in the A.M for the changed scenario( because i followed exactly what u did but it's probably insufficient for present requirements.)
I have made a view which is the combination of 5 tables, i have defined the VO accordingly
so the search is working fine but there are lot of issues when i want to update/delete/a dd.
plz provide some clarity about how to define the methods in AM accordingly.
Do reply.
i have created three radio buttons, but by default three are enabled when i am running the page.
my requirement is when the form is running only one button is enable and also when i am select first radio button remaing are deselect.
so please send the code in adf technology and also which components are used i.e. selectBooleanRa dioButton, SelectOneRadio, ShowOneRadio.
thanks
Srinivas SL
at oracle.apps.fnd .framework.webu i.OAJSPApplicat ionRegistry.reg isterApplicatio nModule(OAJSPAp plicationRegist ry.java:279)
at oracle.apps.fnd .framework.webu i.OAJSPApplicat ionRegistry.reg isterApplicatio nModule(OAJSPAp plicationRegist ry.java:78)
at oracle.apps.fnd .framework.webu i.OAPageBean.pr eparePage(OAPag eBean.java:1166 )
at oracle.apps.fnd .framework.webu i.OAPageBean.pr eparePage(OAPag eBean.java:497)
at oracle.apps.fnd .framework.webu i.OAPageBean.pr eparePage(OAPag eBean.java:418)
at _oa__html._OA._ jspService(_OA. java:88)
at oracle.jsp.runt ime.HttpJsp.ser vice(HttpJsp.ja va:119)
at oracle.jsp.app. JspApplication. dispatchRequest (JspApplication .java:417)
at oracle.jsp.JspS ervlet.doDispat ch(JspServlet.j ava:267)
at oracle.jsp.JspS ervlet.internal Service(JspServ let.java:186)
a t oracle.jsp.JspS ervlet.service( JspServlet.java :156)
at javax.servlet.h ttp.HttpServlet .service(HttpSe rvlet.java:588)
at oracle.jsp.prov ider.Jsp20Reque stDispatcher.fo rward(Jsp20Requ estDispatcher.j ava:162)
at oracle.jsp.runt ime.OraclePageC ontext.forward( OraclePageConte xt.java:187)
at _oa__html._RF._ jspService(_RF. java:102)
at oracle.jsp.runt ime.HttpJsp.ser vice(HttpJsp.ja va:119)
at oracle.jsp.app. JspApplication. dispatchRequest (JspApplication .java:417)
at oracle.jsp.JspS ervlet.doDispat ch(JspServlet.j ava:267)
at oracle.jsp.JspS ervlet.internal Service(JspServ let.java:186)
a t oracle.jsp.JspS ervlet.service( JspServlet.java :156)
at javax.servlet.h ttp.HttpServlet .service(HttpSe rvlet.java:588)
at org.apache.jser v.JServConnecti on.processReque st(JServConnect ion.java:456)
a t org.apache.jser v.JServConnecti on.run(JServCon nection.java:29 4)
at java.lang.Threa d.run(Thread.ja va:534)
at oracle.apps.fnd .framework.webu i.OAJSPApplicat ionRegistry.reg isterApplicatio nModule(OAJSPAp plicationRegist ry.java:279)
at oracle.apps.fnd .framework.webu i.OAJSPApplicat ionRegistry.reg isterApplicatio nModule(OAJSPAp plicationRegist ry.java:78)
at oracle.apps.fnd .framework.webu i.OAPageBean.pr eparePage(OAPag eBean.java:1166 )
at oracle.apps.fnd .framework.webu i.OAPageBean.pr eparePage(OAPag eBean.java:497)
at oracle.apps.fnd .framework.webu i.OAPageBean.pr eparePage(OAPag eBean.java:418)
at _oa__html._OA._ jspService(_OA. java:88)
at oracle.jsp.runt ime.HttpJsp.ser vice(HttpJsp.ja va:119)
at oracle.jsp.app. JspApplication. dispatchRequest (JspApplication .java:417)
at oracle.jsp.JspS ervlet.doDispat ch(JspServlet.j ava:267)
at oracle.jsp.JspS ervlet.internal Service(JspServ let.java:186)
a t oracle.jsp.JspS ervlet.service( JspServlet.java :156)
at javax.servlet.h ttp.HttpServlet .service(HttpSe rvlet.java:588)
at oracle.jsp.prov ider.Jsp20Reque stDispatcher.fo rward
the error says
oracle.app s.fnd.framework .OAException: Could not load application module 'oracle.apps.fn d.frame.sehema. PersonAM'
try this on server
ls -l $JAVA_TOP/oracl e/apps/fnd/fram e/sehema/Person AM*
Looks like you got some typos
Also, it helps to see the full error stack
Thanks,
Anil Passi
Thanks & regards
Brajesh
Now i am able to get the page
Thanks & regards
Brajesh
You have given solution to deploying a OA Framework page in server but Can we download a OA Framework page from the server ?
If yes , after downloding can we do some modification on that page?
Thank You.
You can use jdr_utils for that purpose, i think the api name is printdocument
You can google on jdr_utils and find the info.
Having said so, why do you wish to download page from database.
Simpl y get that page from $PRODUCT_TOP/md s/../../
Thank s,
Anil
After downloading the page from the database i want do some modification on that as well as i want to add something on that.
Can i Do that?
is there any process for it?
I'm having one problem...when I hit a "Create Person" button on main page...It's giving following error message.
Exce ption:
oracle.adf.mds .MetadataDefExc eption: Unable to find component with absolute reference = /oracle/apps/ak /xxperson/webui /managePersonPG , XML Path = C:\jdev_install _dir\jdevhome\j dev\myclasses\J RADXML;C:\jdev_ install_dir\jde vhome\jdev\mypr ojects;C:\jdev_ install_dir\jde vbin\jdev\oamds xmlwk. Please verify that the reference is valid and the definition of the component exists either on the File System or in the MDS Repository.
at oracle.adf.mds. internal.Metada taManagerBase.f indElement(Meta dataManagerBase .java:1350)
at oracle.adf.mds. MElement.findEl ement(MElement. java:97)
at oracle.apps.fnd .framework.webu i.JRAD2AKMapper .getRootMElemen t(JRAD2AKMapper .java:501)
at oracle.apps.fnd .framework.webu i.OAWebBeanFact oryImpl.getWebB eanTypeDataFrom JRAD(OAWebBeanF actoryImpl.java :3718)
at oracle.apps.fnd .framework.webu i.OAWebBeanFact oryImpl.getRoot ApplicationModu leClass(OAWebBe anFactoryImpl.j ava:3451)
at oracle.apps.fnd .framework.webu i.OAPageBean.pr eparePage(OAPag eBean.java:999)
at oracle.apps.fnd .framework.webu i.OAPageBean.pr eparePage(OAPag eBean.java:502)
at oracle.apps.fnd .framework.webu i.OAPageBean.pr eparePage(OAPag eBean.java:423)
at _OA._jspService (OA.jsp:40)
at com.orionserver .http.OrionHttp JspPage.service (OrionHttpJspPa ge.java:56)
at oracle.jsp.runt imev2.JspPageTa ble.service(Jsp PageTable.java: 317)
at oracle.jsp.runt imev2.JspServle t.internalServi ce(JspServlet.j ava:465)
at oracle.jsp.runt imev2.JspServle t.service(JspSe rvlet.java:379)
at javax.servlet.h ttp.HttpServlet .service(HttpSe rvlet.java:853)
at com.evermind.se rver.http.Servl etRequestDispat cher.invoke(Ser vletRequestDisp atcher.java:727 )
at com.evermind.se rver.http.Servl etRequestDispat cher.forwardInt ernal(ServletRe questDispatcher .java:306)
at com.evermind.se rver.http.Servl etRequestDispat cher.forward(Se rvletRequestDis patcher.java:20 9)
at com.evermind.se rver.http.GetPa rametersRequest Dispatcher.forw ard(GetParamete rsRequestDispat cher.java:189)
at com.evermind.se rver.http.Everm indPageContext. forward(Evermin dPageContext.ja va:199)
at _OA._jspService (OA.jsp:45)
at com.orionserver .http.OrionHttp JspPage.service (OrionHttpJspPa ge.java:56)
at oracle.jsp.runt imev2.JspPageTa ble.service(Jsp PageTable.java: 317)
at oracle.jsp.runt imev2.JspServle t.internalServi ce(JspServlet.j ava:465)
at oracle.jsp.runt imev2.JspServle t.service(JspSe rvlet.java:379)
at javax.servlet.h ttp.HttpServlet .service(HttpSe rvlet.java:853)
at com.evermind.se rver.http.Servl etRequestDispat cher.invoke(Ser vletRequestDisp atcher.java:727 )
at com.evermind.se rver.http.Servl etRequestDispat cher.forwardInt ernal(ServletRe questDispatcher .java:306)
at com.evermind.se rver.http.HttpR equestHandler.p rocessRequest(H ttpRequestHandl er.java:767)
at com.evermind.se rver.http.HttpR equestHandler.r un(HttpRequestH andler.java:259 )
at com.evermind.se rver.http.HttpR equestHandler.r un(HttpRequestH andler.java:106 )
at EDU.oswego.cs.d l.util.concurre nt.PooledExecut or$Worker.run(P ooledExecutor.j ava:803)
at java.lang.Threa d.run(Thread.ja va:534)
OAF can not find the XML file in location below
jdevHome Directorymyproj ectsoracleappsa kxxpersonwebuim anagePersonPG.x ml
Thanks,
Ani l Passi
I have managePersonPG. xml at the right location
jdevHomeDirectory/\myprojects\xxt\oracle\apps\ak\xxperson\webui\managePersonPG. xml
Still I'm getting the same error message. Could you pls help me out?
Thx
Kal123
I have resolved this issue...It's working good...thx for your help.
Kal
I am having one problem here. When I hit "create Person" button, It opens up "insert and Update Person" page with personId, Firstname, LastName, email, studentFlag,Nam eofUniversity filled with last record, I suppose all fields should be blank when latter page is opened up.
In addition to that there is one more issue I have, After I fill in fields with new record and hit "Commit Data", then Previous record is getting overwritten (Infact existing record being deleted) in underlying XX_PERSON_DETAI LS table.
Could you pls advise me on this where I went wrong ?
Thanks!!
For the CreatePerson, from processRequest, you need to initialize VO so that it points to a fresh new vanilla record in memory.
Thanks ,
Anil Passi
I am getting following error while trying to run main Page.
The target xxPersonMainCO. java cannot be started as a servlet, because the class xxt.oracle.apps .ak.xxperson.we bui.xxPersonMai nCO does not extend javax.servlet.G enericServlet.
The target xxPersonMainCO. java cannot be started as an application, because the class xxt.oracle.apps .ak.xxperson.we bui.xxPersonMai nCO does not have a main method.
Please advise me on this issue.
Thanks!!!
The following is the code that I've used from your tutorial. This code is in ProcessRequest Method of Controller Class for xxManagePersonP G
public void processRequest( OAPageContext pageContext, OAWebBean webBean)
{
super.processRe quest(pageConte xt, webBean);
String paramPersonActi on = pageContext.get Parameter("xxPa ramActionOnPers on");
String paramPersonId = pageContext.get Parameter("xxPa ramPersonId");
OAApplicationMo dule personam = pageContext.get ApplicationModu le(webBean);
Serializable personParamList [] = {paramPersonActi on,paramPersonId};
if (paramPersonActi on !=null && paramPersonActi on.equals("createPerson"))
{
personam.invoke Method("createP ersonMethod", personParamList );
}
}
The following is the code for CreatePersonMet hod in Application Module.
public void createPersonMet hod(String pAction, String pPersonId)
{
OAViewObjectImp l pervo = getXxPersonDeta ilsVO1();
if( !pervo.isPrepar edForExecution( ))
{
pervo.executeQu ery();
Row prow = pervo.createRow ();
pervo.insertRow (prow);
prow.setNewRowS tate(Row.STATUS _INITIALIZED);
}
}
You're sayin "For the CreatePerson, from processRequest, you need to initialize VO so that it points to a fresh new vanilla record in memory." I think, we're already initializing VO as per code given above
OAViewObjectImp l pervo = getXxPersonDeta ilsVO1();
Could you please help me where I'm missing here? Please tell me where exactly we need to initialize Vo sothat it points to New record in memory.
Thanks !!!
1) Entity Definition class
2)Entity Collection class
3) Entity Object class
thanks for your knowledge. i am getting this error and wonder if you know why . the error is no current row for view when i try to save. any suggestions
tha nks
james
I'm new to OAF and your videos are very helpful.
I'm having a little bit of trouble, I can't find the control buttons of steps 1 and 2. There's no way to pause and play the video. Please help.
Thanks!!
Derri ck
RSS feed for comments to this post