tag:blogger.com,1999:blog-23800282968649878322024-03-05T22:13:48.168-08:00ADF Dev to DevADF 11g, BI Publisher, SOAHusainDhttp://www.blogger.com/profile/08119731737785573060noreply@blogger.comBlogger10125tag:blogger.com,1999:blog-2380028296864987832.post-49341114614968365512013-04-24T12:49:00.000-07:002013-04-24T12:49:50.351-07:00JDeveloper Settings<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; line-height: 18px;">Referred from various blogs and documentation. Adding here for quick reference.</span><br />
<span style="background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; line-height: 18px;"><br /></span>
<span style="background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; line-height: 18px;">C:\Oracle\Middleware\jdeveloper\ide\bin\ide.conf</span><br />
<br />
<div style="background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: small; line-height: 18px;">
###### HD Custom ######</div>
<div style="background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: small; line-height: 18px;">
<br /></div>
<div style="background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: small; line-height: 18px;">
AddVMOption -Xms512m</div>
<div style="background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: small; line-height: 18px;">
AddVMOption -Xmx2g</div>
<div style="background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: small; line-height: 18px;">
AddVMOption -XX:MaxPermSize=1g</div>
<div style="background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: small; line-height: 18px;">
<br /></div>
<div style="background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: small; line-height: 18px;">
</div>
###### HD Custom ######<br />
<div>
<br /></div>
<div>
<br /></div>
<br />
<br />
<span style="background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; line-height: 18px;"><br /></span>
<span style="background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; line-height: 18px;"><br /></span>
<span style="background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; line-height: 18px;">C:\Oracle\Middleware\jdeveloper\jdev\bin\jdev.conf</span><br />
<span style="background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 13px; line-height: 18px;"><br /></span>
<span style="background-color: white;"><span style="color: #666666; font-family: Trebuchet MS, Trebuchet, Verdana, sans-serif; font-size: x-small;"></span></span><br />
<div style="line-height: 18px;">
<span style="color: #666666; font-family: Trebuchet MS, Trebuchet, Verdana, sans-serif; font-size: x-small;">###### HD Custom ######</span></div>
<div style="line-height: 18px;">
<span style="color: #666666; font-family: Trebuchet MS, Trebuchet, Verdana, sans-serif; font-size: x-small;"><br /></span></div>
<div style="line-height: 18px;">
<span style="color: #666666; font-family: Trebuchet MS, Trebuchet, Verdana, sans-serif; font-size: x-small;">AddVMOption -Xms512m</span></div>
<div style="line-height: 18px;">
<span style="color: #666666; font-family: Trebuchet MS, Trebuchet, Verdana, sans-serif; font-size: x-small;">AddVMOption -Xmx2g</span></div>
<div style="line-height: 18px;">
<span style="color: #666666; font-family: Trebuchet MS, Trebuchet, Verdana, sans-serif; font-size: x-small;">AddVMOption -XX:MaxPermSize=1g</span></div>
<div style="line-height: 18px;">
<span style="color: #666666; font-family: Trebuchet MS, Trebuchet, Verdana, sans-serif; font-size: x-small;"><br /></span></div>
<div style="line-height: 18px;">
<span style="color: #666666; font-family: Trebuchet MS, Trebuchet, Verdana, sans-serif; font-size: x-small;">AddVMOption -XX:+AggressiveOpts</span></div>
<div style="line-height: 18px;">
<span style="color: #666666; font-family: Trebuchet MS, Trebuchet, Verdana, sans-serif; font-size: x-small;">AddVMOption -XX:+UseStringCache</span></div>
<div style="line-height: 18px;">
<span style="color: #666666; font-family: Trebuchet MS, Trebuchet, Verdana, sans-serif; font-size: x-small;">AddVMOption -XX:+OptimizeStringConcat</span></div>
<div style="line-height: 18px;">
<span style="color: #666666; font-family: Trebuchet MS, Trebuchet, Verdana, sans-serif; font-size: x-small;"><br /></span></div>
<div style="line-height: 18px;">
<span style="color: #666666; font-family: Trebuchet MS, Trebuchet, Verdana, sans-serif; font-size: x-small;">#</span></div>
<div style="line-height: 18px;">
<span style="color: #666666; font-family: Trebuchet MS, Trebuchet, Verdana, sans-serif; font-size: x-small;"># only since Java 6 update 21 performance release</span></div>
<div style="line-height: 18px;">
<span style="color: #666666; font-family: Trebuchet MS, Trebuchet, Verdana, sans-serif; font-size: x-small;"># reduces memory consumption</span></div>
<div style="line-height: 18px;">
<span style="color: #666666; font-family: Trebuchet MS, Trebuchet, Verdana, sans-serif; font-size: x-small;"># reducing memory addressing length overhead</span></div>
<div style="line-height: 18px;">
<span style="color: #666666; font-family: Trebuchet MS, Trebuchet, Verdana, sans-serif; font-size: x-small;">#</span></div>
<div style="line-height: 18px;">
<span style="color: #666666; font-family: Trebuchet MS, Trebuchet, Verdana, sans-serif; font-size: x-small;">AddVMOption -XX:+UseCompressedStrings</span></div>
<div style="line-height: 18px;">
<span style="color: #666666; font-family: Trebuchet MS, Trebuchet, Verdana, sans-serif; font-size: x-small;">AddVMOption -XX:+ScavengeBeforeFullGC</span></div>
<div style="line-height: 18px;">
<span style="color: #666666; font-family: Trebuchet MS, Trebuchet, Verdana, sans-serif; font-size: x-small;">AddVMOption -XX:+UseCompressedOops</span></div>
<div style="line-height: 18px;">
<span style="color: #666666; font-family: Trebuchet MS, Trebuchet, Verdana, sans-serif; font-size: x-small;"><br /></span></div>
<div style="line-height: 18px;">
<span style="color: #666666; font-family: Trebuchet MS, Trebuchet, Verdana, sans-serif; font-size: x-small;">#</span></div>
<div style="line-height: 18px;">
<span style="color: #666666; font-family: Trebuchet MS, Trebuchet, Verdana, sans-serif; font-size: x-small;"># only for multi-core machines</span></div>
<div style="line-height: 18px;">
<span style="color: #666666; font-family: Trebuchet MS, Trebuchet, Verdana, sans-serif; font-size: x-small;">#</span></div>
<div style="line-height: 18px;">
<span style="color: #666666; font-family: Trebuchet MS, Trebuchet, Verdana, sans-serif; font-size: x-small;">AddVMOption -XX:+UseConcMarkSweepGC</span></div>
<div style="line-height: 18px;">
<span style="color: #666666; font-family: Trebuchet MS, Trebuchet, Verdana, sans-serif; font-size: x-small;">AddVMOption -XX:+UseGCOverheadLimit</span></div>
<div style="line-height: 18px;">
<span style="color: #666666; font-family: Trebuchet MS, Trebuchet, Verdana, sans-serif; font-size: x-small;"><br /></span></div>
<div style="line-height: 18px;">
<span style="color: #666666; font-family: Trebuchet MS, Trebuchet, Verdana, sans-serif; font-size: x-small;">##### HD Custom END #####</span></div>
<div style="line-height: 18px;">
<span style="color: #666666; font-family: Trebuchet MS, Trebuchet, Verdana, sans-serif; font-size: x-small;"><br /></span></div>
<div style="line-height: 18px;">
<span style="color: #666666; font-family: Trebuchet MS, Trebuchet, Verdana, sans-serif; font-size: x-small;"><br /></span></div>
<div style="line-height: 18px;">
<span style="color: #666666; font-family: Trebuchet MS, Trebuchet, Verdana, sans-serif; font-size: x-small;"><br /></span></div>
<span style="color: #666666; font-family: Trebuchet MS, Trebuchet, Verdana, sans-serif; font-size: x-small;"><span style="line-height: 18px;">C:\Users\<user>\AppData\Roaming\JDeveloper\system11.1.1.7.40.64.93\DefaultDomain\bin\</user></span><span style="font-size: 13px; line-height: 18px;">setDomainEnv.cmd</span></span><br />
<span style="background-color: white;"><span style="color: #666666; font-family: Trebuchet MS, Trebuchet, Verdana, sans-serif; font-size: x-small;"><span style="font-size: 13px; line-height: 18px;">Add</span><br />
<span style="font-size: 13px; line-height: 18px;"><br /></span>
<span style="font-size: 13px; line-height: 18px;">set USER_MEM_ARGS=-Xms512m -Xmx2g -XX:MaxPermSize=1g</span><br />
<span style="line-height: 18px;"><br /></span></span></span></div>
HusainDhttp://www.blogger.com/profile/08119731737785573060noreply@blogger.com0tag:blogger.com,1999:blog-2380028296864987832.post-87989953686861116542010-10-21T23:11:00.000-07:002010-10-21T23:11:10.385-07:00Building Select one choice with images (using menus.. huh?)I was reading Frank's article "How-to build a single select one choice component with images in the select item list" and wanted to share a method that we used to achieve similar result without a custom component.<br />
The secret Menu and menu items.<br />
<br />
<a href="http://husain-adf.googlecode.com/files/NewApplication.zip">Download the sample application from here</a>.<br />
To run the application add ADFUtils.java file to the app. It runs on HR schema.<br />
<br />
In the sample application the state field is created using a menu. and the select items are created as commandMenuItems.<br />
The advantage of using menu is we get whole list of features thats available with menu like grouping, sub menus, floating menus, images, shortcuts etc<br />
<br />
The Menu items text property is bound to VO attribute #{bindings.StateProvince.inputValue}<br />
<br />
Each commandMenuItem has an actionListener pointing to a backing bean method that sets the value of StateProvince attribute.<br />
<br />
<br />
That's it. Heres how the final output looks like:<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwqvI1HWM1lokEJkSd2tupte9_zuh4JhZLE_b5KQYDKNoVrFYocBXZCiNzA-mfdKuz7aj5QS83q9_Hn2TY7VOjYLza1M3An0bAnoEBjiUMou6JoAWoXmPC_X_JyBOfzxZbsLYZgmLiBY8/s1600/select_one_menu.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="382" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwqvI1HWM1lokEJkSd2tupte9_zuh4JhZLE_b5KQYDKNoVrFYocBXZCiNzA-mfdKuz7aj5QS83q9_Hn2TY7VOjYLza1M3An0bAnoEBjiUMou6JoAWoXmPC_X_JyBOfzxZbsLYZgmLiBY8/s640/select_one_menu.png" width="640" /></a></div>HusainDhttp://www.blogger.com/profile/08119731737785573060noreply@blogger.com0tag:blogger.com,1999:blog-2380028296864987832.post-85134376782327713302010-05-31T22:53:00.000-07:002010-05-31T23:02:18.369-07:00How to Default an LOV with its first valueIts a frequent requirement to default the first value of LOV when a new record is created.<br />
<br />
Heres how to make it happen: <a href="http://husain-adf.googlecode.com/files/TestLOVDefault.zip">DOWNLOAD</a><br />
<br />
In the following example when a new department is created the first location is defaulted. User can then change location. This example can be extended to default only in certain conditions.<br />
<br />
DepartmentEO:<br />
Now since all business logic is in EO the logic needs to be written in EO. <br />
The VO that we would create for LOV on locationId attribute is added as accessor in DepartmentsEO.<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSMvZpGJ0LRNw7ZqhYTjo6agcANddn-qo4lFIZMgmmA4z6UrGWjY33JUbyaFoQ8k5a5A6lnLm5_Pn9H27FHJr6Sj2T0Ogpw-Ntna5ujrmoZ8EgHceVk5ho0VW1E4cLaLlFk9ReoXqFdoI/s1600/EOLov.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="362" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSMvZpGJ0LRNw7ZqhYTjo6agcANddn-qo4lFIZMgmmA4z6UrGWjY33JUbyaFoQ8k5a5A6lnLm5_Pn9H27FHJr6Sj2T0Ogpw-Ntna5ujrmoZ8EgHceVk5ho0VW1E4cLaLlFk9ReoXqFdoI/s640/EOLov.JPG" width="640" /></a> <br />
On LocationId add the groovy expression as follows.<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi55uk3kC3tgmo7a8QLuwQz_X7rg_Uj5pwcQn8OcR8qulkHoVkLoCOh9UUH2DJBJT6gMPUc0rlGvKpkoZ16mkhX3IPrI5ul8UxN5obxQDYgsbrD7Kwmu1NU0bKKS5LURWw3ECg6QXFjLs8/s1600/EOLocationId.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi55uk3kC3tgmo7a8QLuwQz_X7rg_Uj5pwcQn8OcR8qulkHoVkLoCOh9UUH2DJBJT6gMPUc0rlGvKpkoZ16mkhX3IPrI5ul8UxN5obxQDYgsbrD7Kwmu1NU0bKKS5LURWw3ECg6QXFjLs8/s640/EOLocationId.JPG" width="640" /></a> <br />
<br />
The main logic is in the defaultLocationId() where we use the accessor VO to get the first record and set its locationId<br />
public Number defaultLocationId() {<br />
<br />
Number locId = (Number)getAttributeInternal(LOCATIONID);<br />
if (locId == null) {<br />
LocationsVORowImpl locRow = (LocationsVORowImpl)getLocationsVO1().first();<br />
if (locRow != null) {<br />
locId = locRow.getLocationId();<br />
}<br />
}<br />
return locId;<br />
}<br />
<br />
DepartmentsVO:<br />
Create a LOV on locationId attribute. Notice that the view accessor on EO is visible in VO and can be used on LOV.<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAIwUHFFtNGkyUMoUnjCp6AAv9HkwW-UUErPeXPYWikt30VJvyKwAfeVpB-BGWDxqcypy5HFC20pPmPueKBXLRxaYdml17xcYPHDw_s2PYCIB427EGpnTCJvu2GO-h_zEYs8UyvwUz5h4/s1600/LocationsVO.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAIwUHFFtNGkyUMoUnjCp6AAv9HkwW-UUErPeXPYWikt30VJvyKwAfeVpB-BGWDxqcypy5HFC20pPmPueKBXLRxaYdml17xcYPHDw_s2PYCIB427EGpnTCJvu2GO-h_zEYs8UyvwUz5h4/s640/LocationsVO.JPG" width="640" /></a><br />
<br />
Page:<br />
Create a new page with a form based on DepartmentsVO. Also drop CreateNew, Commit and Rollback actions as buttons.<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNzhfIerr4fDNtxN9augIzKAFCwCa6hsOFFUu4yKn0dfgFH4M8g0yvSRogrxGuAL8N74Ajs-bqWO8se4LJijLHygS6283svWXKSV1bfmqkpKstTk55ENdNomw87pKE9ElS_wabbHYhQbU/s1600/PageDesign.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="462" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNzhfIerr4fDNtxN9augIzKAFCwCa6hsOFFUu4yKn0dfgFH4M8g0yvSRogrxGuAL8N74Ajs-bqWO8se4LJijLHygS6283svWXKSV1bfmqkpKstTk55ENdNomw87pKE9ElS_wabbHYhQbU/s640/PageDesign.JPG" width="640" /></a> <br />
<br />
Thats it the groovy expression will do the trick.<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjPJoWkJSIm7Jisspm4YWOUvL_s4U3aKGS8itflGmIk1jKI9z8pEV5fi5Zszbwh1IMXzSg0QeX2pGpxEksG4sOfYRYVxdPU87_3f6bwuDw37POqntkBRxpkabW9xRYa3NYALzuJEgr_jY/s1600/PageRun.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="552" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjPJoWkJSIm7Jisspm4YWOUvL_s4U3aKGS8itflGmIk1jKI9z8pEV5fi5Zszbwh1IMXzSg0QeX2pGpxEksG4sOfYRYVxdPU87_3f6bwuDw37POqntkBRxpkabW9xRYa3NYALzuJEgr_jY/s640/PageRun.JPG" width="640" /></a></div>HusainDhttp://www.blogger.com/profile/08119731737785573060noreply@blogger.com0tag:blogger.com,1999:blog-2380028296864987832.post-48115718915326582052010-03-21T15:52:00.000-07:002010-05-31T21:20:13.305-07:00How to create LOV on a reference attribute (a different approach)<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5ju7_Rd4Niq4SonIZj4ie8MBa9lO1fUM9p8XQVViAE3Kz3darIB-eynccvMU2PRFPScf-GO6Tid3Rp2CyE17dZV9NcnxXbrb-POV7tKhZ7TbGByGLes5DqngHlRkd3R6ZnbKEBC_LAU8/s1600-h/test2.JPG" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><br />
</a><br />
Its always a requirement to display a 'Name' for an attribute and insert 'Value' into the DB table. Creating singleOneChoice is made extremely simple in ADF and it shows Display Name to user but stores internal value in database. However when using inputListOfValues or inputComboboxListOfValues it only brings back the value so we cannot search the 'Name'.<br />
Following screenshots show something we dont usually need:<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjp6YXUPWNdRZ-MJhCKhIQ_TuSDLi0zu3uucGsmZ5Wj33WsrTiHGnw0UgisYh8Mx9r4xABkVOW_An1Y_G1l76ZiuCV-eU8wQOZsnxXmpvw-Moe9jp_6owpEfMylrxEFA-e1SrYP3pZyMWM/s1600-h/Old.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="414" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjp6YXUPWNdRZ-MJhCKhIQ_TuSDLi0zu3uucGsmZ5Wj33WsrTiHGnw0UgisYh8Mx9r4xABkVOW_An1Y_G1l76ZiuCV-eU8wQOZsnxXmpvw-Moe9jp_6owpEfMylrxEFA-e1SrYP3pZyMWM/s640/Old.JPG" width="640" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOshNup6Y4XP_3Kj-cHOWIi45YG06I2vKp0ND357UuNqgEbJwHy8UyIq_rxsrJ6eA_gZjAjbFI75g1trYZEa0izcjXenz6WdTfhTj2JOeVR7VLf7bEbD_-q3nlnjPRO28FbH6IO7QE4WI/s1600-h/Old2.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="402" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOshNup6Y4XP_3Kj-cHOWIi45YG06I2vKp0ND357UuNqgEbJwHy8UyIq_rxsrJ6eA_gZjAjbFI75g1trYZEa0izcjXenz6WdTfhTj2JOeVR7VLf7bEbD_-q3nlnjPRO28FbH6IO7QE4WI/s640/Old2.JPG" width="640" /></a></div><br />
For example in case of HR schema Employees table we need to search & add the manager name but enter managerId into table.<br />
<br />
<br />
This is how I implemented the solution: <a href="http://husain-adf.googlecode.com/files/TestLOVValidation.zip">DOWNLOAD</a><br />
<br />
<ul><li>Create a new update-able transient attribute say ManagerName in the EmployeesView. </li>
<li><br />
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8yfnVvCLQ_vNebvPhaiSJrqdUhRotItB5SGb71w8kdbqq8A7mbH44llWH3xs5Sf7Osh6giL3QKZyyCAuJCHDqfDxPjVR9znfMQlHcfrF1gCcxkfCah45bRZprmkC8JhjTDD_PIrVijWY/s1600-h/ManagerNameAttr.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="384" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8yfnVvCLQ_vNebvPhaiSJrqdUhRotItB5SGb71w8kdbqq8A7mbH44llWH3xs5Sf7Osh6giL3QKZyyCAuJCHDqfDxPjVR9znfMQlHcfrF1gCcxkfCah45bRZprmkC8JhjTDD_PIrVijWY/s640/ManagerNameAttr.JPG" width="640" /></a></div></li>
<li>Create a new read-only VO to fetch manager name and id</li>
<li><br />
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgI_S0Xa0AqZFarz8oj_KwqeCJNwYMpp21e8OF1eLUUHMtEzw5okwEu5w2VsatX-VFuYgAWUFYRzk_wlhZs8Sb_5NEZ-dCtRZuG43q1DKXx9gGOlrv6GfSxD6eiV_QQ3aiCL-ob8axTphk/s1600-h/ManagerVO.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="388" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgI_S0Xa0AqZFarz8oj_KwqeCJNwYMpp21e8OF1eLUUHMtEzw5okwEu5w2VsatX-VFuYgAWUFYRzk_wlhZs8Sb_5NEZ-dCtRZuG43q1DKXx9gGOlrv6GfSxD6eiV_QQ3aiCL-ob8axTphk/s640/ManagerVO.JPG" width="640" /></a></div></li>
<li>Add the manager LOV on ManagerName attribute. Make mappings to return ManagerName and ManagerId. Make List Type as "Input Text with List of Values"</li>
<li><br />
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPvU7rw7LimtEBmWwhF9yUG7ajzmCCbpti4vwYCsE4m7jDk3QqhMe91Oy_zgJGxr1ZadxOO_r2NckkMWPupzac2VYvgWhwoQKo0fVmpVXca7H2ThFOR_8OK73vtP-xn9waEyUZqM4muZg/s1600-h/ManagerLOV.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPvU7rw7LimtEBmWwhF9yUG7ajzmCCbpti4vwYCsE4m7jDk3QqhMe91Oy_zgJGxr1ZadxOO_r2NckkMWPupzac2VYvgWhwoQKo0fVmpVXca7H2ThFOR_8OK73vtP-xn9waEyUZqM4muZg/s400/ManagerLOV.JPG" width="400" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhG_TQwktbOXTaA1AJqoZlXWIM63mIeRN9qMJyDDKao5Kqgdiw4pYPZOIzUiYNpRUOrAJ2cImRYuXu8_eKNkajNkZE62Or2d8owGjYss3wFB0jlZAVeDySV21XzOGHJzO_Nc3V6l3azNW8/s1600-h/ManagerLOV2.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhG_TQwktbOXTaA1AJqoZlXWIM63mIeRN9qMJyDDKao5Kqgdiw4pYPZOIzUiYNpRUOrAJ2cImRYuXu8_eKNkajNkZE62Or2d8owGjYss3wFB0jlZAVeDySV21XzOGHJzO_Nc3V6l3azNW8/s400/ManagerLOV2.JPG" width="400" /></a></div></li>
<li>Now the important step: In the EmployeesViewRowImpl add the following code to getManagerName() method: </li>
<li style="font-family: "Courier New",Courier,monospace;"> public String getManagerName() {<br />
Object mgrId = getAttributeInternal(MANAGERID);<br />
String managerName = null;<br />
if(mgrId != null) {<br />
Object[] obj = {mgrId};<br />
Key key = new Key(obj);<br />
<br />
Row[] rows = getManagersVO1().findByKey(key, 1);<br />
if(rows != null && rows.length > 0) {<br />
managerName = (String)rows[0].getAttribute(1);<br />
}<br />
}<br />
return managerName;<br />
}</li>
<li>The above code basically gets the ManagerName from the Manager LOV for the current ManagerId.</li>
<li>Now when we drop the EmployeesView on page it creates a LOV for ManagerName. Set AutoSubmit = true to make show LOV window on tab out.</li>
<li><br />
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhq4kNNyg9KS-NL8CxpjrsPF_LbtE-gr8PNX-MJj4YjLZ3aHZxflV3VmHCUl6YlXFEPLZFGrTzhGi6TX9QuOO8VI4DAF-BCHstjA7IXF5CWHN9TDyB0Sea8dR83tBUDPYzJFmKBKdLqkwg/s1600-h/ManagerUI.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="388" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhq4kNNyg9KS-NL8CxpjrsPF_LbtE-gr8PNX-MJj4YjLZ3aHZxflV3VmHCUl6YlXFEPLZFGrTzhGi6TX9QuOO8VI4DAF-BCHstjA7IXF5CWHN9TDyB0Sea8dR83tBUDPYzJFmKBKdLqkwg/s640/ManagerUI.JPG" width="640" /></a></div></li>
<li>Just for display I have also added ManagerId column on page. Add partialTrigger to point to ManagerName column.</li>
<li>Run the page to test the application.</li>
<li><br />
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXH5qRR_POQPBxUyn5ewL_0BZACIgdNxzHxxOYG7MNKJ12XW84sBbNbik8tm8Ggg8JOZ_fgw2WbYdHWHQOQVnYPyL97sYpqMhG_yjM2URO-9UW4dWweVGRZJo6HkvYmPp8otS0fnM1QJo/s1600-h/test1.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="347" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXH5qRR_POQPBxUyn5ewL_0BZACIgdNxzHxxOYG7MNKJ12XW84sBbNbik8tm8Ggg8JOZ_fgw2WbYdHWHQOQVnYPyL97sYpqMhG_yjM2URO-9UW4dWweVGRZJo6HkvYmPp8otS0fnM1QJo/s400/test1.JPG" width="400" /></a></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5ju7_Rd4Niq4SonIZj4ie8MBa9lO1fUM9p8XQVViAE3Kz3darIB-eynccvMU2PRFPScf-GO6Tid3Rp2CyE17dZV9NcnxXbrb-POV7tKhZ7TbGByGLes5DqngHlRkd3R6ZnbKEBC_LAU8/s1600-h/test2.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="386" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5ju7_Rd4Niq4SonIZj4ie8MBa9lO1fUM9p8XQVViAE3Kz3darIB-eynccvMU2PRFPScf-GO6Tid3Rp2CyE17dZV9NcnxXbrb-POV7tKhZ7TbGByGLes5DqngHlRkd3R6ZnbKEBC_LAU8/s400/test2.JPG" width="400" /></a></div></li>
</ul><div class="separator" style="clear: both; text-align: center;"></div>HusainDhttp://www.blogger.com/profile/08119731737785573060noreply@blogger.com3tag:blogger.com,1999:blog-2380028296864987832.post-79263214331265212562010-01-06T07:09:00.000-08:002010-01-06T07:53:21.628-08:00Displaying Checkbox based on Database Table (LOV)There are numerous occasions where we need to display checkbox whose value isnt just true/false. eg Y/N, Active/Inactive etc<br />
With the use of LOV feature ADF makes our lives easy when creating dropdowns, LOV etc. Infact this same mechanism can be used to create checkboxes when only 2 possible values exists.<br />
<br />
The demo of this and several other features can be found in the <a href="http://husain-adf.googlecode.com/files/LookupCodesApp_FriDec11115735EST2009.zip">LookupCodeApp</a>.<br />
<br />
Use the following steps:<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoiapp6MqCMOf4xmpYNWiDPj39RzfzAfwRCKEbLx-ZHq7x5hOqEy9Yph4q8BdDgtkOniI5GowjHHW2nn5ZLZO3SzyCCjMl2hHQaZsGT5nzG0LVILBWpidAhmWR_BDCEkm315ywWdA-Hyg/s1600-h/disabledUIHint.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"></a><br />
</div><ul><li>Create a simple VO that queries the checkbox values. Lets say YesNoRVO <br />
</li>
</ul><ul><li>Make sure the query fetches the checked value first. i.e If Y is the value to be inserted when checkbox is checked then Y must be the first query result. The simplest way to do this is using order-by clause.</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNzxRX6ryl1goQAN-UVZsMhUctApedn8u4sQFlvuqaMQJkuTBPJ8wpQxAc-V1733zC6Gq5hXD2tgInMM37pGIJkKQEuvNraybvN2D-RxHroa1HYaQ23zTtNoYijupLhO4gHkp3DlI9N1Y/s1600-h/YNVO.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNzxRX6ryl1goQAN-UVZsMhUctApedn8u4sQFlvuqaMQJkuTBPJ8wpQxAc-V1733zC6Gq5hXD2tgInMM37pGIJkKQEuvNraybvN2D-RxHroa1HYaQ23zTtNoYijupLhO4gHkp3DlI9N1Y/s640/YNVO.jpg" /></a><br />
</div><br />
<ul><li>Open the desired VO and select the attribute that needs to be displayed as a checkbox.</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizjuYOZH_1uX2O75wgy219fFgQNLhgvFVj7YSESBOH3CeY1XZBDy2EkOHE_dUcBrSiOBDQ1cYEcPjFzuyPZu9zPDhrak4MsSiDUh-TgEats6VyBZVXnIoofyly4cZcydQyBxfmblg8lVo/s1600-h/LookupCodeVO.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizjuYOZH_1uX2O75wgy219fFgQNLhgvFVj7YSESBOH3CeY1XZBDy2EkOHE_dUcBrSiOBDQ1cYEcPjFzuyPZu9zPDhrak4MsSiDUh-TgEats6VyBZVXnIoofyly4cZcydQyBxfmblg8lVo/s640/LookupCodeVO.jpg" /></a><br />
</div><ul><li> Create a List of values on the field using YesNoRVO (Checkbox values VO)</li>
</ul><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1kX5cHR07UHB3OCNbXYP95RiB1B_pTkCMdgR6xoQr92SL2rFskAJ70GLcjol95NGqibQcChFQvvN1cgKMFV8eXWiwjlp92VUH0GPgXNQDJRhv1iicdVRrgICGRItYik0VcqWG6v8W_cQ/s1600-h/lov1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1kX5cHR07UHB3OCNbXYP95RiB1B_pTkCMdgR6xoQr92SL2rFskAJ70GLcjol95NGqibQcChFQvvN1cgKMFV8eXWiwjlp92VUH0GPgXNQDJRhv1iicdVRrgICGRItYik0VcqWG6v8W_cQ/s400/lov1.jpg" /></a><br />
</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3SPNCm40qrkoRCJEwQb8_1Uw54GppRmV3sUozqjw8t-xd1NHHn_sKCA1TwJgp3ztmgzv2IoUQnrHg5EequUtHfCqgdFtOnIh63EejtKcr8B5yio6cDEVT-cq4Xb58Tq6NPviFoj9APJk/s1600-h/lov2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><br />
</a><br />
</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3SPNCm40qrkoRCJEwQb8_1Uw54GppRmV3sUozqjw8t-xd1NHHn_sKCA1TwJgp3ztmgzv2IoUQnrHg5EequUtHfCqgdFtOnIh63EejtKcr8B5yio6cDEVT-cq4Xb58Tq6NPviFoj9APJk/s1600-h/lov2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><br />
</a><br />
</div><ul><li>In UI hints tab Leave the "List Type" as it is.</li>
<li>Make sure that "Display Attribute" is the "value" attribute too. This is necessary in cases where the attribute in main VO is of limited size. eg. DisabledFlag is of type varchar(1)</li>
<li><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3SPNCm40qrkoRCJEwQb8_1Uw54GppRmV3sUozqjw8t-xd1NHHn_sKCA1TwJgp3ztmgzv2IoUQnrHg5EequUtHfCqgdFtOnIh63EejtKcr8B5yio6cDEVT-cq4Xb58Tq6NPviFoj9APJk/s1600-h/lov2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3SPNCm40qrkoRCJEwQb8_1Uw54GppRmV3sUozqjw8t-xd1NHHn_sKCA1TwJgp3ztmgzv2IoUQnrHg5EequUtHfCqgdFtOnIh63EejtKcr8B5yio6cDEVT-cq4Xb58Tq6NPviFoj9APJk/s320/lov2.jpg" width="365" /></a><br />
</div> <br />
</li>
<li> </li>
<li>Now for the MOST IMPORTANT change from normal LOV: (Drum roll please...) In the main VO attribute's UI Hints, change the "Control Type" to checkbox.</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoiapp6MqCMOf4xmpYNWiDPj39RzfzAfwRCKEbLx-ZHq7x5hOqEy9Yph4q8BdDgtkOniI5GowjHHW2nn5ZLZO3SzyCCjMl2hHQaZsGT5nzG0LVILBWpidAhmWR_BDCEkm315ywWdA-Hyg/s1600-h/disabledUIHint.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoiapp6MqCMOf4xmpYNWiDPj39RzfzAfwRCKEbLx-ZHq7x5hOqEy9Yph4q8BdDgtkOniI5GowjHHW2nn5ZLZO3SzyCCjMl2hHQaZsGT5nzG0LVILBWpidAhmWR_BDCEkm315ywWdA-Hyg/s400/disabledUIHint.jpg" /></a><br />
</div><br />
<ul><li> The best advantage of this approach is that it can be tested in the Application Module tester as well.</li>
</ul><ul><li>Ofcourse it is re-usable as all checkboxes with Y/N values can use the same YesNoRVO and there is no hard coding necessary.</li>
</ul><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjD62oI8LpyPa7mguMQ2qdk6dZx_8SUM_TXuXQZXPBCBN5FUx6zTldch_4GCetpoSP9yoXsFKvvo4TNuZ7GXaAb6nbmWYFKsR48v1lYcy55u4pr5bcIE9-NL2s0C2KOdoyJjUp5nsoX7c8/s1600-h/chkboxTest.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjD62oI8LpyPa7mguMQ2qdk6dZx_8SUM_TXuXQZXPBCBN5FUx6zTldch_4GCetpoSP9yoXsFKvvo4TNuZ7GXaAb6nbmWYFKsR48v1lYcy55u4pr5bcIE9-NL2s0C2KOdoyJjUp5nsoX7c8/s400/chkboxTest.jpg" /></a><br />
</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNzxRX6ryl1goQAN-UVZsMhUctApedn8u4sQFlvuqaMQJkuTBPJ8wpQxAc-V1733zC6Gq5hXD2tgInMM37pGIJkKQEuvNraybvN2D-RxHroa1HYaQ23zTtNoYijupLhO4gHkp3DlI9N1Y/s1600-h/YNVO.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><br />
</a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxXJ45Jnv2khPEWs7nDG4XfhvaZ_vwC5eRAhU4vqHf3EGjQhyphenhyphenNnlvWbtJUh6YvkBSJb6lHUZmShhCHBoED9Gp2-eBPNvvJI6Enq6Y-XRhRyIMqMfTpyiv_5CZe4wjz1e_Oe_CQx4LVYRI/s1600-h/chkboxTest.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><br />
</a><br />
</div>HusainDhttp://www.blogger.com/profile/08119731737785573060noreply@blogger.com2tag:blogger.com,1999:blog-2380028296864987832.post-40134764692740255482010-01-05T12:33:00.000-08:002010-01-05T12:33:20.481-08:00Declarative Dashboard ComponentADF offers the Dashboard component for arranging a set of portlets (panel boxes, headers, tabs etc) in a grid format. A good demo is found here: http://jdevadf.oracle.com/adf-richclient-demo/faces/components/panelDashboard.jspx<br />
It is the preferred choice of layout when displaying multiple pieces of information in a page. <br />
In our case we have multiple pages that require this component. However the dashboard component in itself is very limited in functionality.<br />
<br />
The demo http://jdevadf.oracle.com/adf-richclient-demo/faces/visualDesigns/dashboard.jspx provides a "richer" dashboard with interface similar to yahoo homepage.<br />
<br />
What I have done here is to use the most important features of the above demo and made a generic declarative component out of it. It can be downloaded from <a href="http://husain-adf.googlecode.com/files/DashboardXApp1.zip">here</a>.<br />
<br />
The declarative component offers the following features:<br />
For Developers:<br />
1. A simple customizable component. Developer can customize number of portlets displayed, whether side-bar is displayed and ofcourse the content of portlets.<br />
2. Developer only needs to drop the component in his page and add header attributes for only the portlets that need to be displayed.<br />
3. All content can be developed independently as page fragments and then dropped into facets offered by the component.<br />
<br />
For Users:<br />
1. Ability to minimize some or all portlets<br />
2. Ability to re-order portlets.<br />
3. Ability to change portlet size<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVs0VusYkC8NFYom8GAKf8Czvwfu5J2Ap8Rdl-F9i9uj-Sz08ZS5bAQhNaHlC1ydhfV6b-fBkmcVZfh2CPaWgGD9Q_k0tq0K89-iaIfG-N6Ud6_GaU7hA2_dw7Nhor-w9vxfu2EIsKJGA/s1600-h/normal.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVs0VusYkC8NFYom8GAKf8Czvwfu5J2Ap8Rdl-F9i9uj-Sz08ZS5bAQhNaHlC1ydhfV6b-fBkmcVZfh2CPaWgGD9Q_k0tq0K89-iaIfG-N6Ud6_GaU7hA2_dw7Nhor-w9vxfu2EIsKJGA/s640/normal.jpg" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4MmQ50nXc2oy04krW1Cm4eNC_92Bk_9WfmQq3K2qllZXrFecrBIuHnM7y2tpdtbEZAaV97CXabQx7PagvdbMx5tRGXz4xKdu48bEb76Z9gjWDHu8PVTSYKkvHD0rAobCtdpuLADfiWXU/s1600-h/re-order.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4MmQ50nXc2oy04krW1Cm4eNC_92Bk_9WfmQq3K2qllZXrFecrBIuHnM7y2tpdtbEZAaV97CXabQx7PagvdbMx5tRGXz4xKdu48bEb76Z9gjWDHu8PVTSYKkvHD0rAobCtdpuLADfiWXU/s640/re-order.JPG" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOFTaFoez_Xyl1qsSTx3vzv5kF4wZv3AM2raMVFZDerp4wtb-F5cLvTYu-3G_jq4G21IEn_Jn9eZ5J8TMFdaLjFPwJwwxHu6nofQzcYfuPkglh62eU9rowLDmiIw66Vc0wg3_4DNGazwE/s1600-h/minimize.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOFTaFoez_Xyl1qsSTx3vzv5kF4wZv3AM2raMVFZDerp4wtb-F5cLvTYu-3G_jq4G21IEn_Jn9eZ5J8TMFdaLjFPwJwwxHu6nofQzcYfuPkglh62eU9rowLDmiIw66Vc0wg3_4DNGazwE/s640/minimize.jpg" /></a><br />
</div>HusainDhttp://www.blogger.com/profile/08119731737785573060noreply@blogger.com2tag:blogger.com,1999:blog-2380028296864987832.post-74959707074302872602009-12-12T13:27:00.000-08:002009-12-12T13:27:28.080-08:00How to manage and use Lookup Codes in ADFEvery application requires the use of LOV (List of values) for selection and data entry. ADF provides a highly declarative way to construct LOV in the ADF-BC layer.<br />
However there remains a challenge to store and maintain lookup codes. It is seldom a good practice to store different lookups in different tables.<br />
Below I have tried to create a sample application that could be used as a guideline for creating lookup maintenance and usage apps.<br />
<br />
It has the following features:<br />
Search Lookups, Create/Edit Types and Codes (obviously).<br />
Ability to (optionally) set translated display values.<br />
Ability to define parent-child relationships between codes. eg country & state. <br />
Ability to (optionally) define & use additional attributes to lookups. eg. country could have attribute 'area'.<br />
Ability to define some lookups as 'reserved' against modifications.<br />
<br />
The application can be <a href="http://www.blogger.com/goog_1260653114229"> </a><a href="http://husain-adf.googlecode.com/files/LookupCodesApp_FriDec11115735EST2009.zip">downloaded from here</a><br />
<br />
<b>Setup</b><br />
I have used JDeveloper 11gR1PS1 but of course ADF 10g and up can be used in similar fashion.<br />
Create the tables using the table_create.sql file in model.lookup.common.diagram package.<br />
Also insert lookup types for Language, YesNo and Validation Method. These are used for creating lookups.<br />
<br />
<br />
<br />
<b>Lookup Maintenance</b><br />
The package model.lookup.common in the Model project contains the EO, VO and AM for maintenance of types, codes, translations and attributes.<br />
To test the maintenance screens run the CodeSearch page in adfc-config.xml. In reality these 3 pages should be in a separate task flow.<br />
<br />
<br />
<b>Lookup Usage</b><br />
There are different ways to use the lookups created:<br />
1. Create different VOs for different lookup types. This approach of course has a disadvantage of repeating the same query in different VO. It is however useful in some cases where a unique way of querying is needed.<br />
eg YesNoCheckboxVO. It is created as separate VO since we needed value 'Y' before 'N' (without bothering about translations). Hence its query contains a order by clause. <br />
<br />
2. Create a common VO with parameters for Type, LangCode and optionally ParentCode. eg. LookupCodesRVO. Then while using, set the parameters in AM instance.<br />
<br />
3. Create a common VO and then create View Criteria for each lookup type. This way while using, developers dont need to remember the lookup type and they can simply choose the lookup criteria they want. However the disadvantage is every new lookup we create, we need to add a view criteria too.<br />
<br />
The page Home.jspx contains a couple of more examples that show how to use parent child lookups are used.<br />
<br />
<br />
Please note that this application is not 100% bug free. Plus there are many other enhancements possible. Do leave a note if you find bugs.HusainDhttp://www.blogger.com/profile/08119731737785573060noreply@blogger.com0tag:blogger.com,1999:blog-2380028296864987832.post-29103627928625063512009-11-12T07:00:00.000-08:002009-11-17T19:32:49.070-08:00Integrating BI Publisher standalone with ADF 10g/11g<div style="font-family: Arial,Helvetica,sans-serif;"><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.25in;"><span style="font-size: small;"><br />
</span><br />
</div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.25in;"><span style="font-size: small;">As we know BI Publisher is one of the best reporting tools available in the market. It is integrated with E-business suite (using OA Framework) and PeopleSoft products hence creating data for reports easy. </span><span style="font-size: small;">However ADF 11g does not come with an integrated BI Publisher support. </span><br />
</div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.25in;"><br />
</div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.25in;"><span style="font-size: small;">OBIEE (Oracle BI Enterprise) </span><span style="font-size: small;">provides different ways to call reports from external applications including ADF. This blog by Venkatakrishnan J explains it thoroughly: <a href="http://oraclebizint.wordpress.com/2008/01/28/oracle-bi-ee-101332-integration-into-external-applicationsportals/">http://oraclebizint.wordpress.com/2008/01/28/oracle-bi-ee-101332-integration-into-external-applicationsportals/</a></span><br />
</div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.25in;"><span style="font-size: small;">However my client has an application in ADF and needed an approach where </span><span style="font-size: small;">existing pages can call reports using existing queries written in View Objects.<br />
<br />
The idea here is to make the integration generic enough so that any page can use it to generate report.<br />
<b></b></span><br />
<span style="font-size: small;">The sample application can be downloaded from <a href="http://husain-adf.googlecode.com/files/BIPIntegrationApp.zip">here</a></span><br />
<span style="font-size: small;"><br />
<b> Step 1: Environment setup</b><br />
</span><br />
</div></div><div><ol style="font-family: Arial,Helvetica,sans-serif;"><ol><li><span style="font-size: small;">The following solution is applicable for both ADF 10g and 11g. I am using ADF 11g installed from </span><span style="font-size: small;"><a href="http://download.oracle.com/otn/java/jdeveloper/111/jdevstudio11111install.exe" target="_blank">http://download.oracle.com/otn/java/jdeveloper/111/jdevstudio11111install.exe</a></span></li>
<li><span style="font-size: small;">Install BI Publisher Desktop from </span><span style="font-size: small;"><a href="http://download.oracle.com/otn/nt/ias/101341/bipublisher_desktop_windows_x86_101341.zip" target="_blank">http://download.oracle.com/otn/nt/ias/101341/bipublisher_desktop_windows_x86_101341.zip</a></span></li>
<li><span style="font-size: small;">Install Oracle XE and configure HR schema. Download Oracle XE from <a href="http://download.oracle.com/otn/nt/oracle10g/xe/10201/OracleXE.exe">http://download.oracle.com/otn/nt/oracle10g/xe/10201/OracleXE.exe</a></span></li>
<li><span style="font-size: small;">Create a new application "Fusion Web Application (ADF)" Call it "BIIntegrationApp"</span></li>
<li><span style="font-size: small;">Copy the jar files from \BI Publisher Desktop\Template Builder for Word\jlib into \BIPIntegrationApp\Model\lib folder. Following the the most important files needed :</span></li>
</ol>
</ol><span style="font-size: small;"><span style="font-family: Arial,Helvetica,sans-serif;"> · xdocore.jar</span><br style="font-family: Arial,Helvetica,sans-serif;" /><span style="font-family: Arial,Helvetica,sans-serif;"> · xmlparserv2-904.jar</span><br style="font-family: Arial,Helvetica,sans-serif;" /><span style="font-family: Arial,Helvetica,sans-serif;"> · collections.jar</span><br style="font-family: Arial,Helvetica,sans-serif;" /><span style="font-family: Arial,Helvetica,sans-serif;"> · i18nAPI_v3.jar</span><br style="font-family: Arial,Helvetica,sans-serif;" /><span style="font-family: Arial,Helvetica,sans-serif;"> · versioninfo.jar</span><br style="font-family: Arial,Helvetica,sans-serif;" /> <br style="font-family: Arial,Helvetica,sans-serif;" /> <b style="font-family: Arial,Helvetica,sans-serif;"> Step 2: Model Project</b><br style="font-family: Arial,Helvetica,sans-serif;" /> </span><br />
<ul style="font-family: Arial,Helvetica,sans-serif;"><li><span style="font-size: small;">Right click the “Model” project and go to "Project Properties" > “Libraries and Classpath”. Click on “Add Jar/Directory” and add all the jar files from </span><span style="font-size: small;">Model/lib folder </span><span style="font-size: small;">.</span></li>
</ul><div class="MsoNormal" style="font-family: Arial,Helvetica,sans-serif; margin: 0in 0in 0.0001pt 0.25in;"><span style="font-size: small;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFYvjz4Vn04IAojW4h5B0ZRPHulUBrDTpRj5kEF3CwSkZKy3sXf8zQlOiH8zdPx_CYpGdLIbR-RIvPvA5uidD1wcUQXQ5t4t01qDIiYFUIwH1_dPoATmxCPgFn_xAuhbDouUVz575XOmw/s1600-h/9-26-2009+4-26-44+PM.jpg"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5386221809285728770" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFYvjz4Vn04IAojW4h5B0ZRPHulUBrDTpRj5kEF3CwSkZKy3sXf8zQlOiH8zdPx_CYpGdLIbR-RIvPvA5uidD1wcUQXQ5t4t01qDIiYFUIwH1_dPoATmxCPgFn_xAuhbDouUVz575XOmw/s320/9-26-2009+4-26-44+PM.jpg" style="height: 232px; margin: 0px auto 10px; text-align: center; width: 320px;" /></a></span><br />
</div><ul style="font-family: Arial,Helvetica,sans-serif;"><li><span style="font-size: small;">Create a new Database connection to HR schema of Oracle XE db.</span></li>
</ul><div class="MsoNormal" style="font-family: Arial,Helvetica,sans-serif; margin: 0in 0in 0.0001pt 0.25in;"><span style="font-size: small;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-DUid8F3G2ouP6lci5fwhUg46kZYwCcf4rUpNEDJx6ASpe0bhWYx1AjRCbfCOdCLnJzFq1ZP6u8acSFGPBQDLIzOdQubnWkn5CBLV8gHGcrgmTxervxLIHO3x3NkBHsByQdj_vzJUo-4/s1600-h/1.png"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5386227296187492402" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-DUid8F3G2ouP6lci5fwhUg46kZYwCcf4rUpNEDJx6ASpe0bhWYx1AjRCbfCOdCLnJzFq1ZP6u8acSFGPBQDLIzOdQubnWkn5CBLV8gHGcrgmTxervxLIHO3x3NkBHsByQdj_vzJUo-4/s320/1.png" style="height: 285px; margin: 0px auto 10px; text-align: center; width: 320px;" /></a><br />
</span> <br />
</div><div class="MsoNormal" style="font-family: Arial,Helvetica,sans-serif; margin: 0in 0in 0.0001pt 0.25in;"><span style="font-size: small;"><br />
</span><br />
</div><ul style="font-family: Arial,Helvetica,sans-serif;"><li><span style="font-size: small;">Create Business Components using “Business Components from Tables”</span></li>
</ul><div class="MsoNormal" style="font-family: Arial,Helvetica,sans-serif; margin: 0in 0in 0.0001pt 0.25in;"><span style="font-size: small;">Select "Employees" and "Departments" tables for creating Entity Objects. Also create default view objects and Default Application Module.</span><br />
</div><div class="MsoNormal" style="font-family: Arial,Helvetica,sans-serif; margin: 0in 0in 0.0001pt 0.25in;"><span style="font-size: small;">Delete the View Links DeptMgrFkLink and EmpManagerFkLink since we wont be using them. We need a simple relation between Department and Employee in our report.</span><br />
</div><div class="MsoNormal" style="font-family: Arial,Helvetica,sans-serif; margin: 0in 0in 0.0001pt 0.25in;"><span style="font-size: small;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsdFBNqOvbqxZ3lsWk0WGEghF8LuloQeqKCByL32KypDZ9DDS9PhWe4mN0kPo7xJP4t-sUBJ-ER8tBbgduDfTFnabwp2FOEdwpK6zEYEKPwKnlZPKXfHq1Yyu6eTqBbKfTIeNopX0x8bc/s1600-h/9-26-2009+4-55-02+PM.png"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5386222335832831282" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsdFBNqOvbqxZ3lsWk0WGEghF8LuloQeqKCByL32KypDZ9DDS9PhWe4mN0kPo7xJP4t-sUBJ-ER8tBbgduDfTFnabwp2FOEdwpK6zEYEKPwKnlZPKXfHq1Yyu6eTqBbKfTIeNopX0x8bc/s320/9-26-2009+4-55-02+PM.png" style="height: 131px; margin: 0px auto 10px; text-align: center; width: 320px;" /></a><br />
</span> <br />
</div><div class="MsoNormal" style="font-family: Arial,Helvetica,sans-serif; margin: 0in 0in 0.0001pt 0.25in;"><span style="font-size: small;"><br />
</span> <br />
</div><ul style="font-family: Arial,Helvetica,sans-serif;"><li><span style="font-size: small;">Next we create a layer of ADF extension classes to put generic code used for report generation. Since the XML data is generated from VO, lets extend the ViewObjectImpl.</span></li>
</ul><div class="MsoNormal" style="font-family: Arial,Helvetica,sans-serif; margin: 0in 0in 0.0001pt 0.25in;"><span style="font-size: small;">Create a new Java class “model.base.BaseViewObjectImpl” which extends “oracle.jbo.server.ViewObjectImpl”</span><br />
</div><div class="MsoNormal" style="font-family: Arial,Helvetica,sans-serif; margin: 0in 0in 0.0001pt 0.25in;"><span style="font-size: small;"><br />
</span><br />
</div><ul style="font-family: Arial,Helvetica,sans-serif;"><li><span style="font-size: small;">In the BaseViewObjectImpl we will add at least 2 methods getXMLData() and getReport(). {Other overridden methods can be added to pass different parameters}</span></li>
</ul><div class="MsoNormal" style="font-family: Arial,Helvetica,sans-serif; margin: 0in 0in 0.0001pt 0.25in;"><br />
</div><div class="MsoNormal" style="font-family: Arial,Helvetica,sans-serif; margin: 0in 0in 0.0001pt 0.25in;"><span style="font-size: small;">getXMLData() will generate XML representation of the View Object Data</span><br />
</div><div class="MsoNormal" style="font-family: Arial,Helvetica,sans-serif; margin: 0in 0in 0.0001pt 0.25in;"><span style="font-size: small;"><br />
</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 0.75in;"><span style="font-size: small;">public byte[] getXMLData() {</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 75pt;"><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.25in;"><span style="font-size: small;">byte[] dataBytes = null;</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.25in;"><span style="font-size: small;">try {</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">ByteArrayOutputStream outputStream = new ByteArrayOutputStream();</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">//The following statement will generate xml representation of the view data.</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">//the first param of writeXML takes the number of levels of child nodes to consider.</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">//the entire xml is then printed into the outputStream.</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">((XMLNode)writeXML(4, XMLInterface.XML_OPT_ALL_ROWS)).print(outputStream);</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 0.25in;"><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">//Simple and Dirty way to generate sample XML data is to print the outputStream to log</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">//Then copy the data into xml file.</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">//However it will not be possible to generate large xml file in this way</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">System.out.println(outputStream.toString());</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 103.5pt;"><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">//The reason we convert to byte[] is that outputStream is not serializable</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">//while byte[] is serializable and can be used in client class when needed.</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">dataBytes = outputStream.toByteArray();</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.25in;"><span style="font-size: small;">} catch (IOException e) {</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">System.out.println(e.getMessage());</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.25in;"><span style="font-size: small;">} catch (Exception e) {</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">System.out.println(e.getMessage());</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.25in;"><span style="font-size: small;">} </span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 75pt;"><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.25in;"><span style="font-size: small;">return dataBytes;</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 0.75in;"><span style="font-size: small;">}</span><br />
</div><ul style="font-family: Arial,Helvetica,sans-serif;"><li><span style="font-size: small;">getReport() is the main method that takes the xml data and template file from parameter and converts it into the report of desired format. </span></li>
</ul><div class="MsoNormal" style="font-family: Arial,Helvetica,sans-serif; margin: 0in 0in 0.0001pt 0.25in;"><span style="font-size: small;">Although I am passing the template path and filename, the logic can be modified to fetch the template from database. (that will be in some other post.)</span><br />
</div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.25in;"><span style="font-family: ""; font-size: small;"><br />
</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 0.75in;"><span style="font-size: small;">/**</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 2.25in;"><span style="font-size: small;">getReport method obtains the xml data of the view object and combines it with the template passed to it.</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 2.25in;"><span style="font-size: small;">It then converts the report in the desired format and returns the byte[] array.</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 0.75in;"><span style="font-size: small;">*</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 2.25in;"><span style="font-size: small;">The reason byte[] is passed instead of OutputStream is that OutputStream is not serializable.</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 0.75in;"><span style="font-size: small;">* </span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 2.25in;"><span style="font-size: small;">@param templateFile: File Name with Path of the RTF template file.</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 2.25in;"><span style="font-size: small;">@param outFileType: eg HTML, PDF, RTF</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 0.75in;"><span style="font-size: small;">*/</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 0.75in;"><span style="font-size: small;">public byte[] getReport(String templateFile, String outFileType) {</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 75pt;"><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.25in;"><span style="font-size: small;">byte[] dataBytes = null;</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 0.25in;"><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.25in;"><span style="font-size: small;">try {</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">//Process RTF template to convert to XSL-FO format</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">RTFProcessor rtfp = new RTFProcessor(templateFile);</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">ByteArrayOutputStream xslOutStream = new ByteArrayOutputStream();</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">rtfp.setOutput(xslOutStream);</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">rtfp.process();</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 0.25in;"><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">//Use XSL Template and Data from the VO to generate report and return the OutputStream of report</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">ByteArrayInputStream xslInStream = new ByteArrayInputStream(xslOutStream.toByteArray());</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 0.25in;"><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">FOProcessor processor = new FOProcessor();</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">ByteArrayInputStream dataStream = new ByteArrayInputStream(getXMLData());</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">processor.setData(dataStream);</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">processor.setTemplate(xslInStream);</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 0.25in;"><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">ByteArrayOutputStream pdfOutStream = new ByteArrayOutputStream();</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">processor.setOutput(pdfOutStream);</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">byte outFileTypeByte = FOProcessor.FORMAT_PDF;</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">if ("HTML".equalsIgnoreCase(outFileType)) {</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 2.25in;"><span style="font-size: small;">outFileTypeByte = FOProcessor.FORMAT_HTML;</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">}</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">processor.setOutputFormat(outFileTypeByte); //FOProcessor.FORMAT_HTML</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">processor.generate();</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 0.25in;"><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">dataBytes = pdfOutStream.toByteArray();</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 0.25in;"><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.25in;"><span style="font-size: small;">} catch (IOException e) {</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">e.printStackTrace();</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">System.out.println("IOException when generating pdf "+ e);</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 103.5pt;"><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.25in;"><span style="font-size: small;">} catch (XDOException e) {</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">e.printStackTrace();</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">System.out.println("XDOException when generating pdf "+ e);</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 103.5pt;"><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.25in;"><span style="font-size: small;">}</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.25in;"><span style="font-size: small;">return dataBytes;</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 0.75in;"><span style="font-size: small;">}</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 0.75in;"><span style="font-size: small;"><br />
</span><br />
</div><ul style="font-family: Arial,Helvetica,sans-serif;"><li><span style="font-size: small;">Next we will inherit these methods in DepartmentView by extending BaseViewObjectImpl.</span></li>
</ul><div class="MsoNormal" style="font-family: Arial,Helvetica,sans-serif; margin: 0in 0in 0.0001pt 0.25in;"><span style="font-size: small;">Open the DepartmentsView (View Object), Select the Java tab. Select Generate View Object Class. Also select “Extends button” and extend Object from “BaseViewObjectImpl”</span><br />
</div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.25in;"><span style="font-size: small;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxJFRklPdqnMyeKw8_GDWvj8NiR-fYVc9eLrrZ-QrtGjx0-05VwA7KaXKtHo_ZkWRTE7Sorvyu7muz4Pk63nnRJplOxi6Z9M_xDPSxC4pXckB_74D7-_G7KyShW8C9EwwB7rLgdyhDtvE/s1600-h/9-26-2009+4-57-11+PM.png"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5386222594679780098" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxJFRklPdqnMyeKw8_GDWvj8NiR-fYVc9eLrrZ-QrtGjx0-05VwA7KaXKtHo_ZkWRTE7Sorvyu7muz4Pk63nnRJplOxi6Z9M_xDPSxC4pXckB_74D7-_G7KyShW8C9EwwB7rLgdyhDtvE/s320/9-26-2009+4-57-11+PM.png" style="height: 314px; margin: 0px auto 10px; text-align: center; width: 320px;" /></a></span><br />
</div><ul style="font-family: Arial,Helvetica,sans-serif;"><li><span style="font-size: small;">In the “DepartmentsViewImpl” add the following code. It will use the getReport() from base class. This code is not necessary if we plan to pass templatePath from UI directly.</span></li>
</ul><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 0.75in;"><span style="font-size: small;">public byte[] getReport(String format) {</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.25in;"><span style="font-size: small;">//Some complex logic to derive the template path based on language, customer type etc..</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.25in;"><span style="font-size: small;">String templatePath = "C:\tmp\template1.rtf";</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.25in;"><span style="font-size: small;">return getReport( </span><span style="font-size: small;">templatePath, format);</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 0.75in;"><span style="font-size: small;">}</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 0.75in;"><span style="font-size: small;"><br />
</span><br />
</div><ul style="font-family: Arial,Helvetica,sans-serif;"><li><span style="font-size: small;">Now create a client interface for DepartmentsView and shuttle in getReport(String). Only this method will be visible in Data Control later.</span></li>
</ul><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.25in;"><span style="font-size: small;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijrDp0q_oEcMRVd53CVi953ZjNfHjEPotd2fOVUhC8iEI85Mm7TNlIduS5H9WEnky4N3LeZ_Neoeax9m76zaTQ7MFL7ophjWc7XZ0G-ckjfRxOhkex9NtTlqXow9zflh-L89_dljQ4nk8/s1600-h/9-26-2009+5-50-49+PM.png"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5386222700461055250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijrDp0q_oEcMRVd53CVi953ZjNfHjEPotd2fOVUhC8iEI85Mm7TNlIduS5H9WEnky4N3LeZ_Neoeax9m76zaTQ7MFL7ophjWc7XZ0G-ckjfRxOhkex9NtTlqXow9zflh-L89_dljQ4nk8/s320/9-26-2009+5-50-49+PM.png" style="height: 202px; margin: 0px auto 10px; text-align: center; width: 320px;" /></a></span><br />
</div><ul style="font-family: Arial,Helvetica,sans-serif;"><li><span style="font-size: small;">Compile the model project. Resolve compilation errors if any.</span></li>
</ul><ul style="font-family: Arial,Helvetica,sans-serif;"><li><span style="font-size: small;">At this point its a good idea to run the Application Module and run the method getReport() to check if it generates the report. We will be able to download the report later once UI project is complete.<br />
</span></li>
</ul></div><div style="font-family: Arial,Helvetica,sans-serif;"><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.25in;"><span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;"><br />
</span><br />
</div><span style="font-size: small;"> <b> Step 3: ViewController Project. </b><br />
</span><br />
</div><div><ul style="font-family: Arial,Helvetica,sans-serif;"><li><span style="font-size: small;">Create a new JSF Page. </span><span style="font-size: small;">Name the page DepartmentEmployees.jspx. Do NOT create backing bean, we will create a managed bean.</span></li>
</ul><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.25in;"><span style="font-size: small;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEha1Q4is6ji-VKeqhYIQMMUsQ1ynSOP53T9ePeSTHktDGn8GVide1ZZ7oWDMKqK4q8oZElxKkDHb14IU4qSp6dgttVQ6Nv8zsdXwTN96DzPXURGafG6r-JJUUXX2KYHs_7UDdJs9U2cKFU/s1600-h/9-26-2009+6-12-30+PM.png"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5386222881463996002" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEha1Q4is6ji-VKeqhYIQMMUsQ1ynSOP53T9ePeSTHktDGn8GVide1ZZ7oWDMKqK4q8oZElxKkDHb14IU4qSp6dgttVQ6Nv8zsdXwTN96DzPXURGafG6r-JJUUXX2KYHs_7UDdJs9U2cKFU/s320/9-26-2009+6-12-30+PM.png" style="height: 213px; margin: 0px auto 10px; text-align: center; width: 320px;" /></a></span><br />
</div><ul style="font-family: Arial,Helvetica,sans-serif;"><li><span style="font-size: small;">Select the getReport(String) method from Data Controls Panel > DepartmentsView1 . Drag it and drop on the page as ADF Parameter Form.</span></li>
</ul><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.25in;"><span style="font-size: small;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVQghY8VjFmpgZpZR4jvUBlgBVJcgbKSmTAyD7RmEpRq41oHY7QoCGCYp8tWewbymDzP5hiOIzaAnWrcPbCDTCuihbK8cuaF3rtA7VAjia-hEUGMf5whxM4MQ54PdhQn3t-DHlaw4C0TE/s1600-h/9-26-2009+6-19-19+PM.png"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5386223398784969218" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVQghY8VjFmpgZpZR4jvUBlgBVJcgbKSmTAyD7RmEpRq41oHY7QoCGCYp8tWewbymDzP5hiOIzaAnWrcPbCDTCuihbK8cuaF3rtA7VAjia-hEUGMf5whxM4MQ54PdhQn3t-DHlaw4C0TE/s320/9-26-2009+6-19-19+PM.png" style="height: 194px; margin: 0px auto 10px; text-align: center; width: 320px;" /></a></span><br />
</div><div class="MsoNormal" style="font-family: Arial,Helvetica,sans-serif; margin: 0in 0in 0.0001pt 0.25in;"><span style="font-size: small;">It will create a Textbox that is bound to the parameter of the method. The value entered in the textbox will be passed to getReport() method.</span><br />
</div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.25in;"><span style="font-size: small;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNj_tqkTeRTKZpPihdMXPxqZcUD5hinSs_G7epPHuUX9V5G04gNZYRdQYZgR4N_h1FVamfi4Y6fw1662YgjYViOZrnEAYm9_3uDIzdzBQCH85YYrpChp8eCwDwzxLam5E0sJeehL8cuL4/s1600-h/9-26-2009+6-18-30+PM.png"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5386223395062071906" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNj_tqkTeRTKZpPihdMXPxqZcUD5hinSs_G7epPHuUX9V5G04gNZYRdQYZgR4N_h1FVamfi4Y6fw1662YgjYViOZrnEAYm9_3uDIzdzBQCH85YYrpChp8eCwDwzxLam5E0sJeehL8cuL4/s320/9-26-2009+6-18-30+PM.png" style="height: 267px; margin: 0px auto 10px; text-align: center; width: 320px;" /></a></span><br />
</div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.25in;"><br />
</div><ul style="font-family: Arial,Helvetica,sans-serif;"><li><span style="font-size: small;">You will see it generates a textbox and a button “getReport”. If you run the page and press the button, it will execute the method in VO but not display the report result. <br />
</span></li>
<li><span style="font-size: small;">For the textbox set the AutoSubmit property to 'true'. Ideally this is not needed but since we will add a file download listener, it wont set the values when button is clicked. <br />
</span></li>
</ul><ul style="font-family: Arial,Helvetica,sans-serif;"><li><span style="font-size: small;">In order to download the report, Select “File Download Action Listener” from Component Palette and drop on the “getReport button”.</span></li>
</ul><div class="MsoNormal" style="font-family: Arial,Helvetica,sans-serif; margin: 0in 0in 0.0001pt 0.25in;"><span style="font-size: small;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjt9VaRone3oOvOkIZBii1A313l4dqBUw9FbQFqjP-3MZ67NZCNqWML1zRqvgRvdMWlb38aihZtbeVttuR5FoqBiQiwe17FZhq52996LAjaXDV9B3wGvhnF0DemecYSVoIJMzNQwhxJmTI/s1600-h/9-26-2009+6-21-31+PM.png"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5386223408071646210" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjt9VaRone3oOvOkIZBii1A313l4dqBUw9FbQFqjP-3MZ67NZCNqWML1zRqvgRvdMWlb38aihZtbeVttuR5FoqBiQiwe17FZhq52996LAjaXDV9B3wGvhnF0DemecYSVoIJMzNQwhxJmTI/s320/9-26-2009+6-21-31+PM.png" style="height: 152px; margin: 0px auto 10px; text-align: center; width: 239px;" /></a></span><br />
</div><ul style="font-family: Arial,Helvetica,sans-serif;"><li><span style="font-size: small;">Select the “File Download Action Listener” and in the Property Inspector select the “Edit” next to “Method” property. It will ask to create a new Managed Bean and Handler Method.</span></li>
</ul><div class="MsoNormal" style="font-family: Arial,Helvetica,sans-serif; margin: 0in 0in 0.0001pt 0.25in;"><span style="font-size: small;">{Note that we can give ContentType and Filename here if it is constant. Even if we do not give these it will work fine except the report will open in the same page instead of giving a download dialog.}</span><br />
</div><div class="MsoNormal" style="font-family: Arial,Helvetica,sans-serif; margin: 0in 0in 0.0001pt 0.25in;"><span style="font-size: small;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjK5wYtNFwiNiRiIc838cYRW66V0FvlcVWrwlNR3Q-1eL9hhYkjTsj1DhFTq8x5DefJG8MplCsQZjd86upwAuGUdx16pLX_JAwT4stkq3WdZrlG3s0bUejHmW3-YjIXSjl8cSbTDxqFr6Y/s1600-h/9-26-2009+6-23-14+PM.png"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5386223409134411874" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjK5wYtNFwiNiRiIc838cYRW66V0FvlcVWrwlNR3Q-1eL9hhYkjTsj1DhFTq8x5DefJG8MplCsQZjd86upwAuGUdx16pLX_JAwT4stkq3WdZrlG3s0bUejHmW3-YjIXSjl8cSbTDxqFr6Y/s320/9-26-2009+6-23-14+PM.png" style="height: 110px; margin: 0px auto 10px; text-align: center; width: 320px;" /></a></span><br />
</div><ul style="font-family: Arial,Helvetica,sans-serif;"><li><span style="font-size: small;">Click on the New.. next to Managed Bean Dropdown and create a new java class “view.report.ReportDownloader”</span></li>
</ul><div class="MsoNormal" style="font-family: Arial,Helvetica,sans-serif; margin: 0in 0in 0.0001pt 0.25in;"><span style="font-size: small;">Then create a new Method “handleDeptReportDwd” and press Ok.</span><br />
</div><div class="MsoNormal" style="font-family: Arial,Helvetica,sans-serif; margin: 0in 0in 0.0001pt 0.25in;"><span style="font-size: small;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6Alic_3nKLmSMb3qWTKTBvieU_IX9fzUaN0FlHq7UqxqLkYOaeyCdL3UI9ZOHc3v9Y66-gHoE9iZfkCLe4nMMQkSyIo_yYIvxfeftFnHOS0I-DkQJMbdoWo-XGhG6VMsLIyhrDpYi8vQ/s1600-h/9-27-2009+2-49-16+PM.png"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5386223419491393170" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6Alic_3nKLmSMb3qWTKTBvieU_IX9fzUaN0FlHq7UqxqLkYOaeyCdL3UI9ZOHc3v9Y66-gHoE9iZfkCLe4nMMQkSyIo_yYIvxfeftFnHOS0I-DkQJMbdoWo-XGhG6VMsLIyhrDpYi8vQ/s320/9-27-2009+2-49-16+PM.png" style="height: 104px; margin: 0px auto 10px; text-align: center; width: 320px;" /></a></span><br />
</div><ul style="font-family: Arial,Helvetica,sans-serif;"><li><span style="font-size: small;">Open the ReportDownloader.java and add the following code. It is a generic code (Thanks to <a href="http://blogs.oracle.com/smuenchadf/examples/#152">Steve Muench</a>) that calls a method from data binding and returns it result.</span></li>
</ul><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.25in;"><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 0.75in;"><span style="font-size: small;">/**</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 2.25in;"><span style="font-size: small;">This example illustrates does not specifically set any </span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 2.25in;"><span style="font-size: small;">method action parameter values, so the parameter values</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 2.25in;"><span style="font-size: small;">are picked up from the EL expressions configured on the</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 2.25in;"><span style="font-size: small;">method action binding arguments in the page definition </span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 2.25in;"><span style="font-size: small;">metadata.</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 2.25in;"><span style="font-size: small;">http://blogs.oracle.com/smuenchadf/examples/#152</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 0.75in;"><span style="font-size: small;">*/</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 0.75in;"><span style="font-size: small;">public Object executeMethodWithResult(String methodActionId) {</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.25in;"><span style="font-size: small;">BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.25in;"><span style="font-size: small;">OperationBinding operationBinding = bindings.getOperationBinding(methodActionId);</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.25in;"><span style="font-size: small;">Object result = operationBinding.execute();</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 69.75pt;"><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.25in;"><span style="font-size: small;">if (!operationBinding.getErrors().isEmpty()) {</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">throw new RuntimeException("Error while executing.. "+operationBinding.getErrors());</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.25in;"><span style="font-size: small;">}</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.25in;"><span style="font-size: small;">return result;</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 0.75in;"><span style="font-size: small;">}</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 0.75in;"><span style="font-size: small;"><br />
</span><br />
</div><ul style="font-family: Arial,Helvetica,sans-serif;"><li><span style="font-size: small;">Add the following code to handleDeptReportDwd(). It simply calls the above util method and passes getReport which is id of methodAction tag in DepartmentEmployeesPageDef.xml </span></li>
</ul><div class="MsoNormal" style="font-family: Arial,Helvetica,sans-serif; margin: 0in 0in 0.0001pt 0.25in;"><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 0.75in;"><span style="font-size: small;">public void handleDeptReportDwd(FacesContext facesContext, OutputStream outputStream) {</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.25in;"><span style="font-size: small;">try {</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">Object result = executeMethodWithResult("getReport");</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">outputStream.write((byte[])result);</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.25in;"><span style="font-size: small;">} catch (IOException e) {</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.75in;"><span style="font-size: small;">System.out.println("Exception "+e);</span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 1.25in;"><span style="font-size: small;">} </span><br />
</div><div class="MsoNormal" style="font-family: Courier New; margin: 0in 0in 0.0001pt 0.75in;"><span style="font-size: small;">}</span><br />
</div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.75in;"><br />
</div><div style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;"><br />
<b> Step 4: BI Publisher Template</b><br />
</span><br />
</div><ul style="font-family: Arial,Helvetica,sans-serif;"><li><span style="font-size: small;">The Only reason we didn’t create it earlier was because we needed to get the data xml. And now we can get the data xml by running the DepartmentEmployees page.</span></li>
</ul><ul style="font-family: Arial,Helvetica,sans-serif;"><li><span style="font-size: small;">To get the xml, go to the DepartmentsView and open its client Interface and shuttle in getXMLData method.</span></li>
</ul><div class="MsoNormal" style="font-family: Arial,Helvetica,sans-serif; margin: 0in 0in 0.0001pt 0.25in;"><span style="font-size: small;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnNFE8Lt-MCZlr_xBKJod5L5FYKiK05-szKKYHbE4ZYY4glWDqjCG7f8Nf42s6cdscd4qZTHL-lXt6losrikrsINGY1oWJQJ3sO0OyBZWWzbBK9Li5FXpcaoPnTRgspeXCIPlGPHAoJTg/s1600-h/9-27-2009+2-49-33+PM.png"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5386223552364686562" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnNFE8Lt-MCZlr_xBKJod5L5FYKiK05-szKKYHbE4ZYY4glWDqjCG7f8Nf42s6cdscd4qZTHL-lXt6losrikrsINGY1oWJQJ3sO0OyBZWWzbBK9Li5FXpcaoPnTRgspeXCIPlGPHAoJTg/s320/9-27-2009+2-49-33+PM.png" style="height: 224px; margin: 0px auto 10px; text-align: center; width: 320px;" /></a></span><br />
</div><ul style="font-family: Arial,Helvetica,sans-serif;"><li><span style="font-size: small;">Next open DepartmentEmployees page and drop in the getXMLData() from DataControl and drop it as button. Run the page.</span></li>
</ul><div class="MsoNormal" style="font-family: Arial,Helvetica,sans-serif; margin: 0in 0in 0.0001pt 0.25in;"><span style="font-size: small;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjf9tH0P4ZlbbyzZWyeCV0YNZcaRSNMo902mxAE_vVxx3FDgmaLV_mUdJa_nJ_oVrCoXEhig8GpCK3XJVqb2McmocpTpU97z-cosLTo9lcump9hrMpqJ14pLc3nko7HBs4tCB3reFzKUE0/s1600-h/9-27-2009+2-49-26+PM.png"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5386223549873757970" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjf9tH0P4ZlbbyzZWyeCV0YNZcaRSNMo902mxAE_vVxx3FDgmaLV_mUdJa_nJ_oVrCoXEhig8GpCK3XJVqb2McmocpTpU97z-cosLTo9lcump9hrMpqJ14pLc3nko7HBs4tCB3reFzKUE0/s320/9-27-2009+2-49-26+PM.png" style="height: 94px; margin: 0px auto 10px; text-align: center; width: 290px;" /></a><br />
</span><br />
</div><ul style="font-family: Arial,Helvetica,sans-serif;"><li><span style="font-size: small;"> Since we put the System.out.println() in getXMLData() method, when we execute that method from the page, it will print the xml data in log file. (If your xml file is big, add a “File Download Action Listener” to this button and write another method to download)</span></li>
</ul><ul style="font-family: Arial,Helvetica,sans-serif;"><li><span style="font-size: small;">Copy the xml data and save it in a file depts.xml. </span></li>
</ul><ul style="font-family: Arial,Helvetica,sans-serif;"><li><span style="font-size: small;">Create a new RTF template with the depts.xml and save as DeptTemplate.rtf</span></li>
</ul><div class="MsoNormal" style="font-family: Arial,Helvetica,sans-serif; margin: 0in 0in 0.0001pt 0.25in;"><span style="font-size: small;"><b>Step 5: Run the application</b></span><br />
</div><ul style="font-family: Arial,Helvetica,sans-serif;"><li><span style="font-size: small;">The only thing left is to change the path of template file in DepartmentsViewImpl.java and run the page.</span></li>
</ul></div><div style="font-family: Arial,Helvetica,sans-serif;"><ul><li><span style="font-size: small;">Run the page, enter "pdf" in the textbox and press getReport button to get the report.</span></li>
</ul><span style="font-size: small;"> </span><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6zvzu7Bz2bOReTahY5K8Nm-xTmbD8Vzgdynt4YFhm2cai8igw6y1hTGF2ppDPRl8rgXzNtNICL524hMYm_xyUn2-ASgWLeHCwQ3qfTVKo9Az6SKCV82GNw6Yn3Meg7EfupvU10sCo_uM/s1600/RunPDF.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6zvzu7Bz2bOReTahY5K8Nm-xTmbD8Vzgdynt4YFhm2cai8igw6y1hTGF2ppDPRl8rgXzNtNICL524hMYm_xyUn2-ASgWLeHCwQ3qfTVKo9Az6SKCV82GNw6Yn3Meg7EfupvU10sCo_uM/s400/RunPDF.jpg" /></a><br />
</div><ul><li><span style="font-size: small;"> Enter "HTML" in textbox and click getReport to receive report in HTML format.</span></li>
</ul><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmF_h5Olz2J2xkOzOWeDz0Kk88bQHsX52V-0AW_u-wZh5kWV3WcEejnI_keheHmzroZyBtVAaown2vdjnXhd0F3sTXolQvxTgY4vYSAYVNi4bFPWjhCiYh0VSVj-_iwZzobSIFXGJO1bM/s1600/RunHTML.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmF_h5Olz2J2xkOzOWeDz0Kk88bQHsX52V-0AW_u-wZh5kWV3WcEejnI_keheHmzroZyBtVAaown2vdjnXhd0F3sTXolQvxTgY4vYSAYVNi4bFPWjhCiYh0VSVj-_iwZzobSIFXGJO1bM/s400/RunHTML.jpg" /></a><br />
</div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.25in;"><span style="font-size: small;"><br />
</span><br />
</div><span style="font-size: small;">Hope this helps :)<br />
</span><br />
</div><span style="font-size: small;"><br />
</span>HusainDhttp://www.blogger.com/profile/08119731737785573060noreply@blogger.com9tag:blogger.com,1999:blog-2380028296864987832.post-41510213826377232042009-11-07T20:38:00.000-08:002009-11-16T17:53:07.468-08:00Generic way to handle Soft Delete<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgd2spnnoSOH1kPL6ZRkAfgRTgEjpBqSv3Y5czIkkpVl0tS9xM6GjtHcSrv509EEEuAKo37s9p_vJYaS23CIdg47dYTrrSm13dHCJ252DqcBPRowQ8wHqe1j7iTlLrUejl8e3LpjqNLwSw/s1600-h/delete_flag_attr.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"></a><br />
</div><span style="font-size: small;"></span><br />
<div><span style="font-size: small;"><span style="font-family: Arial;"></span> Using ADF 11g (should work in 10g as well)<br />
There are many cases where we need to mark a row as deleted by setting a flag in database instead of physically deleting it. Fusion developers guide gives a way to achieve this http://download.oracle.com/docs/cd/E15051_01/web.1111/b31974/bcadveo.htm#CEGIBHBC. <br />
However we needed to have this feature in almost all the table mandating a generic solution for soft delete. </span><br />
<span style="font-size: small;">The following code can be downloaded from <a href="http://husain-adf.googlecode.com/files/SoftDeleteApp.zip">here</a> <br />
</span><br />
<br />
<span style="font-size: small;">Heres how I approached it:<br />
</span> <br />
<ol><li><span style="font-size: small;">Create a new History Column for SoftDelete</span></li>
<li><span style="font-size: small;">Create Base Class for Entity Implementation Object and override 2 methods of EntityObjectImpl: remove(), doDML()<br />
</span></li>
<li><span style="font-size: small;">Create an application to test our work<br />
</span></li>
</ol></div><div><span style="font-size: small;"><br />
<b>Step 1: Create a new History Column - soft delete</b><br />
</span> <br />
</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVZ3rkWhTp5Vaf3p4hTxgof_7eIDEAy-Q3e8APsKp2yGULuEYSWwV_knR7F822Fo4NIzg7AF0IqG_hlSsE2m9GFnxtQeFxU5wXbxAL7F3F-WiTLLBxJ8N_RGbf2u8EJXqQH5meI1nQSkA/s1600-h/base_class_def.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"></a><br />
</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6ZEMPBGJIaGkeZoh97OcW3oe2he1mKtHZSFUgwdaYmXv2hK3sglkFnLn6YcHt6KIMx5_QagPzi62KUfSu_JRBkdVYKj3QLLtqurQHpmy7082jEJd4VKWtm64xqJ_vy7Jz4giMUqXeN9A/s1600-h/history_types.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"></a><br />
</div><div><ul><li><span style="font-size: small;">In Jdeveloper Tools > Preferences > Business Components > History Types. Add a new History Type "soft delete" with id 11 (Note that type id's 1-10 is reserved.</span></li>
</ul><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6ZEMPBGJIaGkeZoh97OcW3oe2he1mKtHZSFUgwdaYmXv2hK3sglkFnLn6YcHt6KIMx5_QagPzi62KUfSu_JRBkdVYKj3QLLtqurQHpmy7082jEJd4VKWtm64xqJ_vy7Jz4giMUqXeN9A/s1600-h/history_types.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6ZEMPBGJIaGkeZoh97OcW3oe2he1mKtHZSFUgwdaYmXv2hK3sglkFnLn6YcHt6KIMx5_QagPzi62KUfSu_JRBkdVYKj3QLLtqurQHpmy7082jEJd4VKWtm64xqJ_vy7Jz4giMUqXeN9A/s400/history_types.jpg" /></a><br />
</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVZ3rkWhTp5Vaf3p4hTxgof_7eIDEAy-Q3e8APsKp2yGULuEYSWwV_knR7F822Fo4NIzg7AF0IqG_hlSsE2m9GFnxtQeFxU5wXbxAL7F3F-WiTLLBxJ8N_RGbf2u8EJXqQH5meI1nQSkA/s1600-h/base_class_def.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><br />
</a><br />
</div><span style="font-size: small;"><br />
<b>Step 2: Create Base EntityImpl class</b><br />
</span> <br />
<ul><li><span style="font-size: small;">Create a new Fusion ADF Application and add a new java class that extends oracle.jbo.server.EntityImpl. <br />
</span></li>
</ul><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh08WvQb3qi6mf7vcRIhZe-X-74HTXsPWG3h_R3NwPMXbfdyXxy3_X89dDiSu1jzvoOMimRh_hjXffX07lj2Y7HFuWZmK1anbXWmgYgD3QQpQVMdFuP2iaohCnkNzk8TlFOP0qGS7n2L3A/s1600-h/base_class_java.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh08WvQb3qi6mf7vcRIhZe-X-74HTXsPWG3h_R3NwPMXbfdyXxy3_X89dDiSu1jzvoOMimRh_hjXffX07lj2Y7HFuWZmK1anbXWmgYgD3QQpQVMdFuP2iaohCnkNzk8TlFOP0qGS7n2L3A/s320/base_class_java.jpg" /></a><br />
</div></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiof8biJEgQaAIY11FAR9uqzWMJ7DlDmFi7eFhSSbHO66Xo6pGZEdMR8sbwvC2GplFKJfW0f39CSQg8WlgJUEbE1GnbneuiRTUYWx6vdre26Hp0jAiuWN6CxJLwMyaH_CQMDKUIu0t_gdU/s1600-h/test_create.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><br />
</a><br />
</div><div><ul><li><span style="font-size: small;">In the BaseEntityImpl override the following methods:</span></li>
<ul><li><span style="font-size: small;">remove() - To set the value of column with History type 11 to deleted value.<br />
</span></li>
<li><span style="font-size: small;">doDML() - During delete, to force an entity object to be updated instead of deleted. And during insert to default the value of column with History type 11 to active value.<br />
</span></li>
</ul>
</ul><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiof8biJEgQaAIY11FAR9uqzWMJ7DlDmFi7eFhSSbHO66Xo6pGZEdMR8sbwvC2GplFKJfW0f39CSQg8WlgJUEbE1GnbneuiRTUYWx6vdre26Hp0jAiuWN6CxJLwMyaH_CQMDKUIu0t_gdU/s1600-h/test_create.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiof8biJEgQaAIY11FAR9uqzWMJ7DlDmFi7eFhSSbHO66Xo6pGZEdMR8sbwvC2GplFKJfW0f39CSQg8WlgJUEbE1GnbneuiRTUYWx6vdre26Hp0jAiuWN6CxJLwMyaH_CQMDKUIu0t_gdU/s400/test_create.jpg" /></a><br />
</div><span style="font-size: small;"><br />
<span style="font-family: Courier New;"> private static final byte SOFT_DELETE_TYPE = 11;</span><br style="font-family: Courier New;" /><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> public int getSoftDeleteColumn() {</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> int colIndex = -1;</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> for (AttributeDef def : getEntityDef().getAttributeDefs()) {</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> if (((AttributeDefImpl)def).getHistoryKind() == SOFT_DELETE_TYPE) {</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> colIndex = def.getIndex();</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> }</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> }</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> return colIndex;</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> }</span><br style="font-family: Courier New;" /><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> @Override</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> public void remove() {</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> int deleteCol = getSoftDeleteColumn();</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> if(deleteCol != -1) {</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> setAttribute(deleteCol, "Y");</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> }</span><br style="font-family: Courier New;" /><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> super.remove();</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> }</span><br style="font-family: Courier New;" /><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> @Override</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> protected void doDML(int operation, TransactionEvent transactionEvent) {</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> int deleteCol = getSoftDeleteColumn();</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> if (EntityImpl.DML_DELETE == operation && deleteCol != -1) {</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> operation = DML_UPDATE;</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> }</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> if(EntityImpl.DML_INSERT == operation && deleteCol != -1) {</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> setAttribute(deleteCol, "N");</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> }</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> super.doDML(operation, transactionEvent);</span><br style="font-family: Courier New;" /><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> }</span><br style="font-family: Courier New;" /><br />
</span><br />
</div><div><span style="font-size: small;"><br />
<b>Step 3: Now to the good stuff - Test the base class</b><br />
</span><br />
</div><ul><li><span style="font-size: small;">In Oracle XE HR schema add delete_flag to employees table.</span></li>
<ul><li style="font-family: Courier New;"><span style="font-size: small;">alter table employees<br />
add delete_flag varchar2(1)<br />
<br />
update employees<br />
set delete_flag = 'N'</span></li>
</ul>
</ul><span style="font-size: small;"><br />
</span><br />
<ul><li><span style="font-size: small;">Set the default base entityImpl class for the application using Application > Default Project Properties.</span></li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVZ3rkWhTp5Vaf3p4hTxgof_7eIDEAy-Q3e8APsKp2yGULuEYSWwV_knR7F822Fo4NIzg7AF0IqG_hlSsE2m9GFnxtQeFxU5wXbxAL7F3F-WiTLLBxJ8N_RGbf2u8EJXqQH5meI1nQSkA/s1600-h/base_class_def.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVZ3rkWhTp5Vaf3p4hTxgof_7eIDEAy-Q3e8APsKp2yGULuEYSWwV_knR7F822Fo4NIzg7AF0IqG_hlSsE2m9GFnxtQeFxU5wXbxAL7F3F-WiTLLBxJ8N_RGbf2u8EJXqQH5meI1nQSkA/s400/base_class_def.jpg" /></a><br />
</div><br />
<ul><li><span style="font-size: small;">Create business components (EO, VO & AM) for employees table.</span></li>
</ul><span style="font-size: small;"> <br />
</span><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRnAO-v3Xjwwqo-c8VKcy1N0PIpqWcViUO-RG3w-opbWyXEexl-t0dNk5q4lpZmOFkmEra73Khg2XHfSd2b-FmixB4Yu_uuFCG73Sl5-qVuUe9FqbF6g7qA5ZsJ3g3a0Ykj684fdn8L5A/s1600-h/model_proj.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRnAO-v3Xjwwqo-c8VKcy1N0PIpqWcViUO-RG3w-opbWyXEexl-t0dNk5q4lpZmOFkmEra73Khg2XHfSd2b-FmixB4Yu_uuFCG73Sl5-qVuUe9FqbF6g7qA5ZsJ3g3a0Ykj684fdn8L5A/s400/model_proj.jpg" /></a><br />
</div><ul><li><span style="font-size: small;">In the EmployeesEO set the history column for "DeleteFlag" to "soft delete".</span></li>
</ul><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgd2spnnoSOH1kPL6ZRkAfgRTgEjpBqSv3Y5czIkkpVl0tS9xM6GjtHcSrv509EEEuAKo37s9p_vJYaS23CIdg47dYTrrSm13dHCJ252DqcBPRowQ8wHqe1j7iTlLrUejl8e3LpjqNLwSw/s1600-h/delete_flag_attr.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgd2spnnoSOH1kPL6ZRkAfgRTgEjpBqSv3Y5czIkkpVl0tS9xM6GjtHcSrv509EEEuAKo37s9p_vJYaS23CIdg47dYTrrSm13dHCJ252DqcBPRowQ8wHqe1j7iTlLrUejl8e3LpjqNLwSw/s400/delete_flag_attr.jpg" /></a><br />
</div><ul><li><span style="font-size: small;">Run the Application Module to test insert and delete.<br />
</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiof8biJEgQaAIY11FAR9uqzWMJ7DlDmFi7eFhSSbHO66Xo6pGZEdMR8sbwvC2GplFKJfW0f39CSQg8WlgJUEbE1GnbneuiRTUYWx6vdre26Hp0jAiuWN6CxJLwMyaH_CQMDKUIu0t_gdU/s1600-h/test_create.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiof8biJEgQaAIY11FAR9uqzWMJ7DlDmFi7eFhSSbHO66Xo6pGZEdMR8sbwvC2GplFKJfW0f39CSQg8WlgJUEbE1GnbneuiRTUYWx6vdre26Hp0jAiuWN6CxJLwMyaH_CQMDKUIu0t_gdU/s400/test_create.jpg" /></a><br />
</div><br />
<br />
<br />
</li>
</ul><span style="font-size: small;"><br />
</span>HusainDhttp://www.blogger.com/profile/08119731737785573060noreply@blogger.com2tag:blogger.com,1999:blog-2380028296864987832.post-62031630883104597612009-11-05T21:12:00.000-08:002009-11-08T17:55:50.421-08:00Search from popup and add to a new table<div class="separator" style="clear: both; text-align: left;"><span style="font-size: small;">Using ADF 11g (ADF Faces & ADF-BC) and Oracle XE (HR Schema)<br />
</span><span style="font-size: small;">At a number of occasions I have had to create a Table that would allow user to add new rows from values of existing table. For eg. Consider creating an order by searching and adding a product. In these cases we generally create a popup for searching product and add selected products to Order.<br />
</span><br />
</div><div class="separator" style="clear: both; text-align: left;"><span style="font-size: small;"></span><br />
</div><div class="separator" style="clear: both; text-align: left;"><span style="font-size: small;"></span><br />
</div><div class="separator" style="clear: both; text-align: left;"><span style="font-size: small;"></span><br />
</div><div class="separator" style="clear: both; text-align: left;"><span style="font-size: small;"></span><br />
</div><div class="separator" style="clear: both; text-align: left;"><br />
</div><div class="separator" style="clear: both; text-align: left;"><span style="font-size: small;"> The source code can be downloaded from <a href="http://dl.dropbox.com/u/2906109/SearchNAddApp.zip">here </a><br />
In this sample I will add employees from HR schema into a new table my_employees.<br />
<br />
</span><span style="font-size: small;">1. Create a new table in HR schema: my_employees<br />
<br />
<span style="font-family: Courier New;">drop table my_employees<br />
<br />
create table my_employees<br />
(<br />
id number primary key,<br />
emp_id number,<br />
creation_date date,<br />
update_date date<br />
)<br />
<br />
create sequence my_employees_s<br />
start with 1<br />
increment by 1<br />
<br />
</span></span><span style="font-size: small;"><br />
2. In Model Project:<br />
Create EO, Default VO and AM for tables employees and my_employees tables<br />
Create AO between EmployeesEO and MyEmployeesEO. Also create Impl files for both EOs.<br />
Create VL between EmployeesVO and MyEmployeesVO. <br />
<br />
</span><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2jawFWrBAN6z17jj0YMyHs8WJKHHbTNXfHmfVfTCeq0RrcgyJLUlzi_qZ67P5AtjvtsxVR2hGy5fpiRwJqR_6Qh3M3MYNJH4ghAJJay3dk_R6b07W-4aJhPSiRw_79dpwtDYjhN-DRWo/s1600-h/ModelTree.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2jawFWrBAN6z17jj0YMyHs8WJKHHbTNXfHmfVfTCeq0RrcgyJLUlzi_qZ67P5AtjvtsxVR2hGy5fpiRwJqR_6Qh3M3MYNJH4ghAJJay3dk_R6b07W-4aJhPSiRw_79dpwtDYjhN-DRWo/s320/ModelTree.jpg" /></a><br />
</div><div id="swtn" style="text-align: left;"><span style="font-size: small;"></span><br />
</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjs6fb97Hcghnx5XJFCDKJjSQ6a3YdjVeh0w_Nhi2fzoJvBPX9cCRN2BvqZq2FdqSs852FnqU5Twu37nBa2enKzoVsiPuyBRF7rwj5P5oOil-ub0XxiVulM7aaNAksAovLct-QxoqYulbw/s1600-h/MyEmpVO.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><br />
</a><br />
</div><span style="font-size: small;"><br />
</span><span style="font-size: small;">Add Name, email attributes to MyEmployeesVO from EmployeesEO to display Name and email of selected employees.<br />
<br />
</span><br />
<div id="wlf3" style="text-align: left;"><span style="font-size: small;"></span><br />
</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjs6fb97Hcghnx5XJFCDKJjSQ6a3YdjVeh0w_Nhi2fzoJvBPX9cCRN2BvqZq2FdqSs852FnqU5Twu37nBa2enKzoVsiPuyBRF7rwj5P5oOil-ub0XxiVulM7aaNAksAovLct-QxoqYulbw/s1600-h/MyEmpVO.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjs6fb97Hcghnx5XJFCDKJjSQ6a3YdjVeh0w_Nhi2fzoJvBPX9cCRN2BvqZq2FdqSs852FnqU5Twu37nBa2enKzoVsiPuyBRF7rwj5P5oOil-ub0XxiVulM7aaNAksAovLct-QxoqYulbw/s320/MyEmpVO.jpg" /></a><br />
</div><br />
<span style="font-size: small;"><br />
</span><span style="font-size: small;">In the MyEmployeesEOImpl add the following code to create() method<br />
<span style="font-family: Courier New;"> protected void create(AttributeList attributeList) {</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> super.create(attributeList);</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> SequenceImpl seq = new SequenceImpl("MY_EMPLOYEES_S", getDBTransaction());</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> </span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> setId(seq.getSequenceNumber());</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> setEmpId((Number)attributeList.getAttribute("EmpId"));</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> //setEmpId(new Number(1));</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> }</span><br />
</span><span style="font-size: small;"><br style="font-family: Courier New;" /></span><span style="font-size: small;">Add VOImpl and VORowImpl to EmployeesVO & MyEmployeesVO. This will be used in AM while creating new rows.<br />
<br />
In </span><span style="font-size: small;">AppModuleAMImpl, </span><span style="font-size: small;">create a method addSelectedEmployees(</span><span style="font-size: small;"><span style="font-family: Courier New;">Key[]</span></span><span style="font-size: small;"> selectedEmp). WHY exactly the code uses </span><span style="font-size: small;"><span style="font-family: Courier New;">Key[]</span></span><span style="font-size: small;"><span style="font-family: Courier New;"> will be clear once we create UI.</span><br />
</span><span style="font-size: small;"><span style="font-family: Courier New;"> public void addSelectedEmployees(Key[] selectedEmp) {</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> for(Key key : selectedEmp) {</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> try {</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> //Either get the row using the key</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> //Or since in this case, Key is employeeId we can use key.getAttribute(1) as well</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> EmployeesVOImpl empVO = getEmployees1();</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> EmployeesVORowImpl empRow = (EmployeesVORowImpl)empVO.findByKey(key, 1)[0];</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> NameValuePairs nvp = new NameValuePairs();</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> nvp.setAttribute("EmpId", empRow.getEmployeeId());</span><br style="font-family: Courier New;" /><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> MyEmployeesVOImpl myempVO = getMyEmployees1();</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> MyEmployeesVORowImpl myempRow = (MyEmployeesVORowImpl)myempVO.createAndInitRow(nvp);</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> myempVO.insertRow(myempRow);</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> </span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> } catch (Exception e) {</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> throw new JboException("Error in addSelectedEmployees "+e.getMessage());</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> }</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> }</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"> }</span><br style="font-family: Courier New;" /></span><span style="font-size: small;"><br />
</span><span style="font-size: small;">In the client Interface screen of AM, add the method </span><span style="font-size: small;">addSelectedEmployees in selected list. We create client interface for our method since we will call it from a ViewController via bindings.<br />
<br />
</span><br />
<div id="ctjw" style="text-align: left;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjL7Y9Vxhte4342N0QoVNVFvbF8we-4Et_moAcCxra_a96TvKzOiM1MSUzS07Q_N43NvezjqszMRFHXRe7PvYO3HBh-b2iaC4HyXsYo2_mFuny4qKp-cF4v9YzaCxNEx7lXJUoID8q7sgM/s1600-h/AMClient.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjL7Y9Vxhte4342N0QoVNVFvbF8we-4Et_moAcCxra_a96TvKzOiM1MSUzS07Q_N43NvezjqszMRFHXRe7PvYO3HBh-b2iaC4HyXsYo2_mFuny4qKp-cF4v9YzaCxNEx7lXJUoID8q7sgM/s320/AMClient.jpg" /></a><br />
</div><span style="font-size: small;"><br />
</span><br />
</div><span style="font-size: small;"><br />
At this point its good to execute the AM. However create new row for MyEmployees will not work since it wont get the EmpId.<br />
<br />
3. So Next we turn our attention to ViewController project:<br />
<br />
</span><span style="font-size: small;">Create a page addEmployees.jspx. <br />
All we will add to the page is a rich table for Myemployees and a popup containing query region for employees.<br />
<br />
Add MyEmployees1 from Data Control to the page as read-only table. Enable the 'Row Selection' option<br />
<br />
</span><br />
<div id="c_lh" style="text-align: left;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjkL-tKLTCvwJO7bJd56vqE5GFU-jzsehkB09rx3qr7LMVKT8aAYpbwkRd-unj0PiZMA5bwYMoWN-rQtKq8n0Swkoi87SuQyYAUYxGLHZJsp1yc9peG9N5iVyHQ5rr3aDhw4uA3_HouUE/s1600-h/MyEmpTable.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjkL-tKLTCvwJO7bJd56vqE5GFU-jzsehkB09rx3qr7LMVKT8aAYpbwkRd-unj0PiZMA5bwYMoWN-rQtKq8n0Swkoi87SuQyYAUYxGLHZJsp1yc9peG9N5iVyHQ5rr3aDhw4uA3_HouUE/s320/MyEmpTable.jpg" /></a><br />
</div><span style="font-size: small;"><br />
</span><br />
</div><span style="font-size: small;"><br />
Surround table with a PanelCollection and add 2 buttons 'Add New' and 'Delete' on it.<br />
<br />
</span><br />
<div id="pex0" style="text-align: left;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjy2PtuK8vRJwEBMmuYv0N4XDl3Zg028lSImdaMooOmg1w17WLe5ox_EXhFQDP4Zlfavvybc3pCv8MI6-YVZ3D3N1yrntcsK2eG3SVKtqOCrdFSMGAXbZSwTOA44JfTfu2QPFfDKlasATw/s1600-h/tableCreated.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjy2PtuK8vRJwEBMmuYv0N4XDl3Zg028lSImdaMooOmg1w17WLe5ox_EXhFQDP4Zlfavvybc3pCv8MI6-YVZ3D3N1yrntcsK2eG3SVKtqOCrdFSMGAXbZSwTOA44JfTfu2QPFfDKlasATw/s320/tableCreated.jpg" /></a><br />
</div><span style="font-size: small;"><br />
</span><br />
</div><span style="font-size: small;"><br />
<br />
Next we Add a popup dialog on the page and drop Employees1 as a query region on it. <br />
<br />
</span><span style="font-size: small;">Change the RowSelection for result table to 'multiple' & Note that the 'SelectedRowKeys' is empty while 'SelectionListener' has value <span style="font-family: Courier New;">#{bindings.Employees1.collectionModel.makeCurrent}</span><br />
<br />
</span><br />
<div id="ygg." style="text-align: left;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjy2PtuK8vRJwEBMmuYv0N4XDl3Zg028lSImdaMooOmg1w17WLe5ox_EXhFQDP4Zlfavvybc3pCv8MI6-YVZ3D3N1yrntcsK2eG3SVKtqOCrdFSMGAXbZSwTOA44JfTfu2QPFfDKlasATw/s1600-h/tableCreated.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjy2PtuK8vRJwEBMmuYv0N4XDl3Zg028lSImdaMooOmg1w17WLe5ox_EXhFQDP4Zlfavvybc3pCv8MI6-YVZ3D3N1yrntcsK2eG3SVKtqOCrdFSMGAXbZSwTOA44JfTfu2QPFfDKlasATw/s320/tableCreated.jpg" /></a><br />
</div><span style="font-size: small;"><br />
</span><br />
</div><span style="font-size: small;"><br />
<br />
</span><span style="font-size: small;">In order to open the popup, </span><span style="font-size: small;">add showPopupListener on 'Add New' button and put popupId using 'Edit' dialog. <br />
</span><span style="font-size: small;">In order to delete, Grab Delete operation from MyEmployees1 data control and drop on Delete button.<br />
</span><span style="font-size: small;">Also add PartialTriggers of both buttons on the main table.<br />
<br />
</span><span style="font-size: small;">We can test our page at this point and it should display blank MyEmployees Table. Clicking on the Add New button will display popup and we can search employees. The selected employees however will not be added to MyEmployees. For that we need to add some code in managed bean to get selected employees and pass it to AM method that we created earlier. remember?<br />
<br />
</span><span style="font-size: small;"></span><br />
<div id="a930" style="text-align: left;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkn4lzeK9n0RUe_vbHScwv9CmdYJuzIUXL-d-5Dl5_WAG6KUDwyKdYYV9aAnFOolbDE1SkfkrO2XTK6qzVD0-21fBYiWsW_EfDczQq-Df67T92ybAKp9_gi3W33r3S53GKdYKD6VNlgVg/s1600-h/firstRun.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkn4lzeK9n0RUe_vbHScwv9CmdYJuzIUXL-d-5Dl5_WAG6KUDwyKdYYV9aAnFOolbDE1SkfkrO2XTK6qzVD0-21fBYiWsW_EfDczQq-Df67T92ybAKp9_gi3W33r3S53GKdYKD6VNlgVg/s320/firstRun.jpg" /></a><br />
</div><span style="font-size: small;"><br />
</span><br />
</div><span style="font-size: small;"><br />
<br />
</span><span style="font-size: small;">Go to page definition of addEmployees page. Add a new methodAction: addSelectedEmployees(Key[]) to bindings.<br />
</span><br />
<div id="flak" style="text-align: left;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrmIncN-L5G-0I4k4bzqUbWUeBiRGkZflyoE6T4YkupHY_u9mUcQ7iPV6RYBKe7N5nerRf2M19Zix_UmWT-vrcx2kYJdR8Xv-T73GYruaBCpKFyuS7gfHsGD4aFewCIS-9kG7edYL9LD8/s1600-h/ActionBinding.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrmIncN-L5G-0I4k4bzqUbWUeBiRGkZflyoE6T4YkupHY_u9mUcQ7iPV6RYBKe7N5nerRf2M19Zix_UmWT-vrcx2kYJdR8Xv-T73GYruaBCpKFyuS7gfHsGD4aFewCIS-9kG7edYL9LD8/s320/ActionBinding.jpg" /></a><br />
</div><span style="font-size: small;"><br />
</span><br />
</div><span style="font-size: small;"><br />
</span><span style="font-size: small;">In the dialog listener property of af:dialog </span><span style="font-size: small;">add a method #{EmployeeMgr.handleAddEmployee}. Create the managed bean </span><span style="font-size: small;">EmployeeMgr if not present.<br />
<br />
</span><span style="font-size: small;">Ad</span><span style="font-size: small;">d the following code to </span><span style="font-size: small;">handleAddEmployee() method to</span><span style="font-size: small;"> get all the selected employees from the popup table.<br />
<br style="font-family: Courier New;" /></span><span style="font-size: small;"><span style="font-family: Courier New;"> public void handleAddEmployee(DialogEvent dialogEvent) {</span><br style="font-family: Courier New;" /></span><span style="font-size: small;"> <span style="font-family: Courier New;"> // get all the selected attributes...</span><br style="font-family: Courier New;" /></span><span style="font-size: small;"> <span style="font-family: Courier New;"> if(dialogEvent.getOutcome().equals(DialogEvent.Outcome.ok)) {</span><br style="font-family: Courier New;" /></span><span style="font-size: small;"> <span style="font-family: Courier New;"> //Find the search results table and get all selected values</span><br style="font-family: Courier New;" /></span><span style="font-size: small;"> <span style="font-family: Courier New;"> RichTable table = </span></span><span style="font-size: small;"><span style="font-family: Courier New;">(RichTable)</span></span><span style="font-size: small;"><span style="font-family: Courier New;"> <br />
</span></span><br />
<span style="font-size: small;"><span style="font-family: Courier New;"> findComponent(dialogEvent.getComponent(), "resId1");</span><br style="font-family: Courier New;" /></span><span style="font-size: small;"> <span style="font-family: Courier New;"> RowKeySet set = table.getSelectedRowKeys();</span><br style="font-family: Courier New;" /></span><span style="font-size: small;"> <span style="font-family: Courier New;"> System.out.println("Set of selected </span></span><br />
<span style="font-size: small;"><span style="font-family: Courier New;"> "+set.getSize()+" "+set);</span><br style="font-family: Courier New;" /></span><span style="font-size: small;"> <span style="font-family: Courier New;"> Iterator it = set.iterator();</span><br style="font-family: Courier New;" /></span><span style="font-size: small;"> <span style="font-family: Courier New;"> Key[] keyList = new Key[set.getSize()];</span><br style="font-family: Courier New;" /></span><span style="font-size: small;"> <span style="font-family: Courier New;"> int i = 0;</span><br style="font-family: Courier New;" /></span><span style="font-size: small;"> <span style="font-family: Courier New;"> //Add all the selected Keys to array</span><br style="font-family: Courier New;" /></span><span style="font-size: small;"> <span style="font-family: Courier New;"> while(it.hasNext()) {</span><br style="font-family: Courier New;" /></span><span style="font-size: small;"> <span style="font-family: Courier New;"> Key key = (Key)((List)it.next()).get(0);</span><br style="font-family: Courier New;" /></span><span style="font-size: small;"> <span style="font-family: Courier New;"> keyList[i++] = key;</span><br style="font-family: Courier New;" /></span><span style="font-size: small;"> <span style="font-family: Courier New;"> }</span><br style="font-family: Courier New;" /></span><span style="font-size: small;"> <span style="font-family: Courier New;"> </span><br style="font-family: Courier New;" /></span><span style="font-size: small;"> <span style="font-family: Courier New;"> //Pass the Keys as parameter to method </span></span><br />
<span style="font-size: small;"><span style="font-family: Courier New;"> //addSelectedEmployees</span><br style="font-family: Courier New;" /></span><span style="font-size: small;"> <span style="font-family: Courier New;"> Map<string, object=""> map = new HashMap<string, object="">();</string,></string,></span><br style="font-family: Courier New;" /></span><span style="font-size: small;"> <span style="font-family: Courier New;"> map.put("selectedEmp", keyList);</span><br style="font-family: Courier New;" /></span><span style="font-size: small;"> <span style="font-family: Courier New;"> executeMethodWithParams("addSelectedEmployees", map);</span><br style="font-family: Courier New;" /></span><span style="font-size: small;"> <br style="font-family: Courier New;" /></span><span style="font-size: small;"> <span style="font-family: Courier New;"> //NOTE: following line refreshes the main page</span><br style="font-family: Courier New;" /></span><span style="font-size: small;"> <span style="font-family: Courier New;"> AdfFacesContext.getCurrentInstance()</span></span><br />
<span style="font-size: small;"><span style="font-family: Courier New;"> .addPartialTarget(findComponentInRoot("t1"));</span><br style="font-family: Courier New;" /></span><span style="font-size: small;"> <span style="font-family: Courier New;"> }</span><br />
</span><span style="font-size: small;"><span style="font-family: Courier New;"> }</span><br style="font-family: Courier New;" /></span><span style="font-size: small;"> <br style="font-family: Courier New;" /></span><span style="font-size: small;"> <br style="font-family: Courier New;" /></span><span style="font-size: small;"> </span><span style="font-size: small;">Dont forget to drop the commit and rollback actions from DataControl onto the page to save the changes.<br />
</span><span style="font-size: small;"> <br />
</span><span style="font-size: small;"> The final page will look like this:<br />
<br />
</span><span style="font-size: small;"></span><br />
<div id="l7qe" style="text-align: left;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqcTAtYGhwWi6zPFp3cOV49w6mzuRBM783ogjN-EXie5UAd0W9jFzzS5yPZ3-fkzAnRZPJZGGQTaN-GBB-BrQhZvBx0Q3fWhzcDaqhF1VDiYGY0rKsxhLij1yRfFafLrFR1d37Af87WHY/s1600-h/finalPage.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqcTAtYGhwWi6zPFp3cOV49w6mzuRBM783ogjN-EXie5UAd0W9jFzzS5yPZ3-fkzAnRZPJZGGQTaN-GBB-BrQhZvBx0Q3fWhzcDaqhF1VDiYGY0rKsxhLij1yRfFafLrFR1d37Af87WHY/s320/finalPage.jpg" /></a><br />
</div><span style="font-size: small;"><br />
</span><br />
</div><span style="font-size: small;"><br />
</span><span style="font-size: small;">I hope this is useful. I would surely appreciate your comments and issues in the project.<br />
</span>HusainDhttp://www.blogger.com/profile/08119731737785573060noreply@blogger.com2