rss feed blog search engine
 
Search rss blog search engine
 
Eating Drinking Sleeping Oracle  
Released:  4/10/2008 8:53:24 PM
RSS Link:  http://ranajitsahoo.blogspot.com/feeds/posts/default?alt=rss
Last View 11/20/2009 5:35:41 PM
Last Refresh 11/21/2009 2:40:22 AM
Page Views 5164
Comments:  Read user comments (0)
Share



Description:



Calling BPEL process from java.. Preventing execution of queries when page loads for first time (ADF).. How to prevent navigation thorugh browser back button using java script in ADF page.. Showing confirm dialog box while cancelling transaction using java script in ADF page...


Contents:

Calling BPEL process from java
When I tried to call BPEL process from JAVA following the steps given in BPEL developer guide, I got error:
java.lang.Exception: Failed to create "ejb/collaxa/system/DeliveryBean" bean. exception reported is: "javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)

Then I added code to set initial context and it worked.
I hope following example will be helpful to you.

import com.oracle.bpel.client.Locator;
import com.oracle.bpel.client.dispatch.IDeliveryService;
import com.oracle.bpel.client.NormalizedMessage;

import java.util.Hashtable;
import java.util.Map;

import javax.naming.Context;

import org.w3c.dom.Element;
import org.w3c.dom.Node;

public class BpelClient {
public BpelClient() {
}

public static void main(String[] args) {

try {
// Set Initial context
Hashtable jndi = new Hashtable();
jndi.put(Context.PROVIDER_URL, "ormi://localhost:12401/orabpel");
jndi.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory");
jndi.put(Context.SECURITY_PRINCIPAL, "oc4jadmin");
jndi.put(Context.SECURITY_CREDENTIALS, "welcome1");
jndi.put("dedicated.connection", "true");

//Instantiate locator
Locator locator = new Locator("default", "bpel", jndi);
IDeliveryService deliveryService = (IDeliveryService)locator.lookupService(IDeliveryService.SERVICE_NAME );

//Prepare input message
String xml = "<ssn xmlns="http://services.otn.com" >111222333</ssn>";
NormalizedMessage nm = new NormalizedMessage( );
nm.addPart("payload", xml );

// Call CreditRatingService BPEL process
NormalizedMessage res =
deliveryService.request("CreditRatingService", "process", nm);
System.out.println( "BPELProcess CreditRatingService executed!" );

// Print output
Map payload = res.getPayload();
Element part = (Element)payload.get("payload");
Node outputElement = part.getFirstChild();
System.out.println("Rating: " + outputElement.getNodeValue());


} catch (Exception ex) {
ex.printStackTrace();
} finally {
}
}
}



Preventing execution of queries when page loads for first time (ADF)
Sometimes you want to prevent the automatic execution of a query when page loads for first time.

To achieve this ...

In ADF 10.1.3, add ${adfFacesContext.postback == true} to refresh condition of the iterator that displays the data in your page.

In ADF 11g, add #{!adfFacesContext.initialRender} to refresh condition of the iterator that displays the data in your page.


How to prevent navigation thorugh browser back button using java script in ADF page
Add the following java script to Onload attribute of afh:body tag in ADF page.

if (history.forward() != null) history.forward()


Showing confirm dialog box while cancelling transaction using java script in ADF page.
We come across a situation where we need the user to confirm before cancelling a transaction or confirm before deleting a record. Following example show how to achieve that in ADF page using a java script.

Let us say user is in employee creation page and he wants to cancel and go back to home page. On clicking Cancel button, a java script dialog box appears to confirm the action.


Add the following java script to the Cancel button “Onclick” java script events attribute.

if (confirm('Do you want to cancel?')) {return true;}else {return false;}

If the user clicks OK then Cancel button’s action will be called else Cancel button’s action will be ignored.

Pretty simple……..




Best AJAX-based solution award goes to Oracle
SYS-CON Events offered all delegates at the 6th International AJAXWorld Conference & Expo in San Jose, CA, the opportunity to cast their vote for their favorite AJAX, RIA and Open Source technology provider in five highly competitive categories. The results have been announced, and they are as follows:

Best Overall Enterprise RIA Product
Winner: ICEsoft - ICEfaces

Best SDK
Winner: Adobe - Flex Builder 3

Best Rich Internet Platform
Winner: Adobe - Adobe Flash Platform

Best Open Source RIA Solution
Winner: Adobe Flex

Best AJAX-Based Solution
Winner: Oracle - Oracle JDeveloper 11g


Courtesy: http://linux.sys-con.com/node/808352/print


Integrating ADF with Oracle Apps R12 - Demo
Though I have not tried integrating ADF with Oracle Apps R12, I came across a demo showing the integration. Hope this will be helpful.


What is the difference between ADF and OAF?
Many times people ask me "What is the difference between ADF and OAF?".

This article will help you to differentiate both technologies.


Oracle Jdeveloper 11g documentation online
http://download.oracle.com/docs/cd/E12839_01/index.htm


How to get URL parameter values in backing bean?

FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("param name"));



How to avoid JBO-35007 error?
When row currency validation fails JBO-35007 error is reaised.

Row currency validation safe gaurds ADF application from browser back button issue.

What is browser back button issue?
Form Duncan Mills ""Oracle JDeveloper 10g for Forms and PL/SQL Developers" book :
Users may be accustomed to clicking the browser's Back button to return to the preceding page or the Refresh button to reload the page. This can cause problems with web applications that use a Controller layer, like the JSF controller or Struts, because the browser Back button returns to the preceding page in the browser's page history without calling code in the Controller layer. The controller will therefore, not know the state of the application's data and the preceding page will either not load properly or may place the application into an inconsistent or unstable state. The same problem occurs with the browser's Refresh button, which just reloads the same page, again without calling Controller layer code. This is a problem in all web applications, not only those using J2EE technology or ADF libraries.

How to ignore row currnecy validation?
There are two ways to avoid this validation.(Note: As Row currency validation safe gaurds ADF application from browser back button issue, it is not suggested to ignore row currency validation)

Method I
Set the EnableTokenValidation to false in the page definition file.
1)In the Application Navigator, right-click the JSP page for which you want to disable validation, and choose Go to Pa ge Definition.
2)In the Structure window, right-click the pagenamePageDef node and choose Properties from the context menu.
3)In the PageDef Properties dialog, select the Advanced Properties tab.
4)In the Enable Token Validation box and choose False. The EnableTokenValidation attribute is added to the PageDef.xml file namespace with a value of false.

Method II
Disable row currency validation on an iterator by setting the "StateValidation" property of an iterator to "false" without disabling it for all iterators in the page definition.


How you can access the true value of the selected list item or radio button directly from ADF
ADF manages the selected value of the list item internally and the value that is exposed through the list binding itself is only the index number of the selection in the list. Developers often make the mistake of treating the value of the list binding as one of these expected values and trying to write code or expressions based on that. The simplest way to gain direct access to the true value of an attribute that is populated from a list binding is to create a secondary value binding to the underlying data. This secondary binding can then be used within expressions to access the true value of the attribute.

Details can be found here.


How to override the sort behavior of table column
Add following code to managed bean that is accessed from the table's sort listener. In this example, whenever users try to sort on the DepartmentName by clicking onto the table header, the sort criteria is modified to DepartmentId .

import java.util.ArrayList;
import java.util.List;

import oracle.adf.view.faces.component.core.data.CoreTable;
import oracle.adf.view.faces.event.SortEvent;
import oracle.adf.view.faces.model.SortCriterion;


public class Sortbean {
public Sortbean() {
}

public void onSort(SortEvent sortEvent) {

List sortList = sortEvent.getSortCriteria();
SortCriterion sc = (SortCriterion) sortList.get(0);

//override sort by DepartmentName and make it sort by DepartmentId instead
if (((String)sc.getProperty()).equalsIgnoreCase("DepartmentName")){
System.out.println("You wanted to sort " +sc.getProperty());

sortList = new ArrayList();
SortCriterion sc2 = new SortCriterion("DepartmentId",true);
System.out.println("This is what I want you to sort for "+sc2.getProperty());
sortList.add(sc2);

CoreTable ct = (CoreTable)sortEvent.getComponent();
ct.setSortCriteria(sortList);
}
}
}




Refreshing Table after Inline Delete
To refresh a table data after inline delete, add the following code after delete logic in managed bean.

AdfFacesContext.getCurrentInstance().addPartialTarget(TableId)


ADF Component Library with Example
ADF 10g Tag Library
ADF 11g Tag Library


How to get Reference of one Managed Bean from other Managed Bean

FacesContext ctx = FacesContext.getCurrentInstance();
Application app = ctx.getApplication();
MyManagedBeanClass mb = (MyManagedBeanClass) app.getVariableResolver().resolveVariable(ctx,"MyManagedBean");



How to Implement Dependent Drop Down List in ADF
In this How-to example, I am going to explain, how dependent drop down list can be implemented in ADF.

Here I am creating two drop down lists "Department" and "Employee".
On selecting department, the list of employees will change.


I am assuming that you have sample HR schema installed in your database.

Create View Object DepartmentListVO for Department SelectItems.
Query: Select department_id, department_name from departments

Create View Object EmployeeListVO for Employee SelectItems.
Query: select employee_id, first_name from employees where dapartment_id = :DeptId

Define Bind variables DeptId in EmployeeListVO

Create View Object EmpDeptVO for defining the form elements.
This query varies according to your requirement. At least include employee_id and department_id in your select clause.

Define an Application Module and add above view objects to this application module.

Create a jspx page, drag EmpDeptVO to the jspx page and drop EmpDeptVO as ADF form.

Delete form elements for employee_id and department_id from the page.

Drag DepartmentId from data control under EmpDeptVO and drop as select one choice.
Click on add to define binding for List. Select DepartmentListVO from the Add data source drop down.
Select Display Attribute as DepartmentName.

Id of this select one chioce is auto populated as selectOneChoice1
Drag EmployeeId from data control under EmpDeptVO and drop as select one choice.
Click on add to define binding for List. Select EmployeeListVO from the Add data source drop down.
Select Display Attribute as FirstName.

Id of this select one chioce is auto populated as selectOneChoice2

Select selectOneChoice1 in structure window and go to properties.
Set AutoSubmit property to true

Select selectOneChoice2 in structure window and go to properties.
Set PartialTruggers property to selectOneChoice1
          <af:selectOneChoice value="#{bindings.Departmentid.inputValue}"
label="Department"
id="selectOneChoice1" autoSubmit="true"">
<f:selectItems value="#{bindings.Departmentid.items}"
id="selectItems1"/>
</af:selectOneChoice>
<af:selectOneChoice value="#{bindings.Employeeid.inputValue}"
label="Employee"
id="selectOneChoice2"
partialTriggers="selectOneChoice1">
<f:selectItems value="#{bindings.Employeeid.items}"
id="selectItems2"/>
</af:selectOneChoice>


Right click on the page and go to page definition.
Right click on Bindings -Select 'Insert Inside Bindings' - Select 'Generic Bindings' - select 'Action'

Select EmployeeListVO from data collection
Select Iterator as EmployeeListVOIterator
Select Operation as ExecuteWithParams
Set the value of parameter 'DeptId' as #{bindings.Departmentid.inputValue}
Click OK

Right click on executables - Select 'Insert Inside executables' - select 'InvokeAction'

Give one meaningful id 'InvokeExecuteWithParams'.
Set 'Binds' as 'ExecuteWithParams'
Set 'Refresh' as 'RenderModel'
Click Finish

Drag InvokeExecuteWithParams above EmployeeListVOIterator

Run the page.

  <bindings>
<action IterBinding="EmployeeListVOIterator" id="ExecuteWithParams"
InstanceName="HRAppModuleDataControl.EmployeeListVO"
DataControl="HRAppModuleDataControl" RequiresUpdateModel="true"
Action="executeWithParams">
<NamedData NDName="DeptId"
NDValue="#{bindings.Departmentid.inputValue}"
NDType="oracle.jbo.domain.Number"/>
</action>
..........
..........
</bindings>

<executables>
<invokeAction id="InvokeExecuteWithParams" Binds="ExecuteWithParams"
Refresh="renderModel"/>
<iterator Binds="EmployeeListVOIterator" RangeSize="-1"
DataControl="HRAppModuleDataControl" id="EmployeeListVOIterator"/>
...........
...........
</executables>



How to implement drop down list in ADF
In this how-to example I am defining a department drop down list, which shows a list of departments.

Add the following code in the ADF page.

          <af:selectOneChoice label="Department"
value="#{ModelData.department}">
<f:selectItems value="#{DepartmentOptions.departments}"/>
</af:selectOneChoice>

In ADF, selectOneChoice is used for drop down list.

selectOneChoice picks the list of values from 'selectItems' tag.

You can define a managed bean to bind an ArrayList of SelectItem objects to 'selectItems'. or can define a view object and bindings. In this example I have defined a managed bean which provides an ArrayList of SelectItem objects.

Department list Backing bean code.

import java.util.ArrayList;
import java.util.List;

import javax.faces.model.SelectItem;

public class DepartmentOptions {



Home  
 



Link to us




RSS Feed of new blogs                                                   Home        Feed Map        Submit Feed      Link to Us       Contact