Search This Blog

control the speed of JMS Consumer

There is an activation agent which can be used to control the speed at which the adapter posts messages to BPEL 


in 11G the setting would be configured as a binding property in the composite.xml the corresponding (inbound) <service>, e.g. 


<service name="Inbound">
<interface.wsdl interface="http://xmlns.oracle.com/pcbpel/demo1#wsdl.interface(SampleInbound_PortType)"/>
<binding.jca config="Dequeue_jms.jca">
<property name="minimumDelayBetweenMessages">1000</property> ------ this is the property that is being implemented.
</binding.jca>
</service> 



This setting ensures that there at least will be 1000 milliseconds delay between the two consecutive messages being posted to the BPEL process.


Note: this setting pertains only to BPEL, and only to one adapter polling thread. If multiple adapter polling threads (e.g. multiple JMS dequeuer threads) have been configured, this setting will control the speed of each thread, not the combined speed.


By implementing the above mentioned solution, I would like to highlight one point though, you need to keep in mind that the delay will happen all the time regardless of heavy or light load.

SOA 11g- Set Custom JMS Header properties In Mediator & BPEL

In this post, I will show you how you can set custom JMS header properties in Mediator and BPEL components.

By Default a JMS message includes a number of header fields that contain information used to identify and route messages. The supported headers for an incoming message are:

Ø JMSCorrelationID
Ø   JMSDeliveryMode
Ø   JMSExpiration
Ø   JMSMessageID
Ø   JMSPriority
Ø   JMSRedelivered
Ø   JMSTimestamp
Ø   JMSType

But we can also set Custom properties.

Mediator: To set custom JMS header property in Mediator follows below steps.

Ø  Open .mplan file and click on assign activity. Here we are defining new custom header property (city).
Ø  To set city custom header property choose “jca.jms.JMSProperty” and append “.city” to it. You can assign any expression or hard-code this property value.








 





BPEL: To set custom JMS header property in BPEL follows below steps.
·         Go to *.bpel file, check the invoke code and add a new property called jca.jms.JMSProperty.city, for instance:

<invoke name="Invoke1" inputVariable="Invoke1_Produce_Message_InputVariable"
            partnerLink="Produce_Message" portType="ns1:Produce_Message_ptt"
            operation="Produce_Message" bpelx:invokeAsDetail="no">
              <bpelx:inputProperty name="jca.jms.JMSProperty.city" variable="cityVar"/>
 </invoke>


 

Currently this property is equal to cityVar but you can also use expression to assign value to city property.

              <bpelx:inputProperty name="jca.jms.JMSProperty.city" expression="2"/>

Remember you will not find this property in header tab, you need to manually set this property in *.bpel file for specific invoke.

When you will run the composite, you will see custom JMS header property at admin console for that queue.




Message Selector Proprty in JMS :


I will show you how to set Message Selector property in JMS adapter to filter the incoming message based on custom JMS header property.We use Message Selector property when your messaging application needs to filter the messages it receives.

 This field is also optional. It filters messages based on header and property information. The message selector rule is a Boolean expression. If the expression is true, then the message is consumed. If the expression is false, then the message is rejected. 

For example, you can enter logic, such as:  city in ( 'Mohali', 'Mumbai', 'Delhi')


Message Selector Property
I explained how to set custom JMS header property. In this post I will show you how to set Message Selector property in JMS adapter to filter the incoming message based on custom JMS header property.
We use Message Selector property when your messaging application needs to filter the messages it receives.
This field is also optional. It filters messages based on header and property information. The message selector rule is a Boolean expression. If the expression is true, then the message is consumed. If the expression is false, then the message is rejected.
For example, you can enter logic, such as:
·         city in (‘Mohali’, 'Mumbai', 'Delhi')
·         city=’Mohali’

To set the Message selector property, open JMS adapter configuration Wizard. Here you can set Message selector property as shown in below diagram.
- See more at: http://soawork.blogspot.de/2013/10/message-selector-property-jms-adapter.html#sthash.eBG71n2u.dpuf

Dynamically enable or disable items of ADF bound List (af:selectOneChoice) -Oracle ADF

This tutorial is about a requirement of conditionally enabling/disabling items (values) of adf bound List (af:selectOneChoice) component
here i am taking reference of default HR Schema (Departments and Location table )

See the steps-
  • Create a Fusion Web Application and business components using both tables
  •  Now create List of Values (Lov) on locationId of departments VO from Location VO
  • Set List Attribute to LocationId and for UI city will be shown
  • Now Drag Departments VO from Data Control on page as a form
  •  Select LocationId list field and delete f:selectItems from it, now drag af:selectItem as child of af:selectOneChoice and surround it with af:forEach 
  • Add tree binding of Location ViewObject to page bindings in order to populate list items using forEach
  •  Now select af:forEach and set its property and variable name, as we have to iterate through Location VO for list items
  •  Again select af:selectItem and set its value and label property using forEach variable's  
  • Now run your application, and see that list box is ready with values
  • Now we have to disable its values as a condition basis, i have written an Expression on af:selectItem's disabled property


  • I have written condition for DepartmentId 100 and 110, see in source of page

  • <af:selectOneChoice value="#{bindings.LocationId.inputValue}" label="#{bindings.LocationId.label}"
                                            required="#{bindings.LocationId.hints.mandatory}"
                                            shortDesc="#{bindings.LocationId.hints.tooltip}" id="soc1"
                                            contentStyle="width:150px;color:red;">
                            <af:forEach items="#{bindings.Locations1.rangeSet}" var="list">
                                <af:selectItem label="#{list.City}" id="si1" value="#{list.LocationId}"
                                               disabled="#{ (bindings.DepartmentId.inputValue==100 and (list.LocationId==1000 || list.LocationId==1300)) || (bindings.DepartmentId.inputValue==110 and (list.LocationId==1500 || list.LocationId==1600 || list.LocationId==1700 || list.LocationId==1800 || list.LocationId==1900))}"/>
                            </af:forEach>
                        </af:selectOneChoice>
    

  • Now value given in Expression for Location Id will be disabled for given Department
  • Run your page and select DepartmentId 100 and 110 to see disabled list items


EO Code snippet for ADF

Creating an entity instance


    public DepartmentEOImpl createDeptEntity() {
        //Find the entity definition from the implementation class
        EntityDefImpl departmentEODef = DepartmentEOImpl.getDefinitionObject();
        //Create the blank entity instance
        DepartmentEOImpl newDept = (DepartmentEOImpl)departmentEODef.createInstance2(this.getDBTransaction(), null);
        newDept.setDepartmentId(1000);
        try {
            getDBTransaction().commit();
        } catch (JboException ex) {
            getDBTransaction().rollback();
            throw ex;
        }
        return newDept;
    }

Find and update an entity row

    public void findAndUpdateDeptEntity(Integer deptId) {
        //Create Key
        Key key = DepartmentEOImpl.createPrimaryKey(deptId);
        //Find the entity row
        DepartmentEOImpl deptRow =
            (DepartmentEOImpl)DepartmentEOImpl.getDefinitionObject().findByPrimaryKey(getDBTransaction(), key);
        deptRow.setDepartmentName("IT Admin");
    }

Remove an entity row

    public void findAndRemoveDeptEntity(Integer deptId) {
        Key key = DepartmentEOImpl.createPrimaryKey(deptId);
        DepartmentEOImpl deptRow = (DepartmentEOImpl)DepartmentEOImpl.getDefinitionObject().findByPrimaryKey(getDBTransaction(), key);
        deptRow.remove();
    }

Find the entity object by using primary key

    private DepartmentEOImpl findDepartmentById(int deptId) {
        //Find the entity definition from the implementation class
        EntityDefImpl departmentEODef = DepartmentEOImpl.getDefinitionObject();
        //Create the Key object
        Key orderKey = DepartmentEOImpl.createPrimaryKey(new Integer(deptId));
        //Find and return the desired instance
        return (DepartmentEOImpl)departmentEODef.findByPrimaryKey(getDBTransaction(), orderKey);
    }

To programmatically access the destination entities using the association accessor generated on entity implementation class

    private DepartmentEOImpl findDepartmentById(int deptId) {
        EntityDefImpl deptEODef = DepartmentEOImpl.getDefinitionObject();
        //Find Creates the Key to find Department
        Key deptIdKey = DepartmentEOImpl.createPrimaryKey(new Integer(deptId));
        //Find the Department entity using deptId
        DepartmentEOImpl deptEOImpl = (DepartmentEOImpl)deptEODef.findByPrimaryKey(getDBTransaction(), deptIdKey);
        //Access Employees for this departament using association accessor getEmpEO() generated on DepartmentEOImpl class
        RowIterator rowIter = DepartmentEOImpl.getEmpEO();
        while (rowIter.hasNext()) {
            Row row = rowIter.next();
            //Row represent Emp entity instance
            //Business logic goes here
        }
    }

Accessing the ADF Binding Layer from Java

BindingContext and BindingContainer

BindingContext is a container object that holds a list of available data controls and data binding objects. It is the Java representation of all cpx files marked in your adfm.xml file. Whereas the BindingContainer class represents Java representation of the page definition file.

   import oracle.adf.model.BindingContext;
   import oracle.binding.BindingContainer;
   ...
   ...
    public BindingContainer getBindings() {
        return BindingContext.getCurrent().getCurrentBindingsEntry();
    }

The DCBindingContainer class exposes more methods than are defined by the BindingContainer interface.

import oracle.adf.model.binding.DCBindingContainer;
...
DCBindingContainer bindings = (DCBindingContainer)this.getBindings();

DCIteratorBinding
It is used to access the rowset iterator of a view object.

import oracle.adf.model.binding.DCIteratorBinding;
import oracle.jbo.Row;
...
DCBindingContainer bc = (DCBindingContainer) getBindings();
DCIteratorBinding iteratorBinding = bc.findIteratorBinding("DepartmentsIterator");
//Execute VO query by executing iterator
iteratorBinding.executeQuery();
//To gets the underlying view object for the iterator
//ViewObject vo = iteratorBinding.getViewObject();
Row currentRow = iteratorBinding.getCurrentRow();
OperationBinding

import oracle.binding.OperationBinding;
...
...
    public void updateDepartmentRow(Row currentDeptRow) {
        BindingContainer bindings = getBindings();
        OperationBinding operationBinding = bindings.getOperationBinding("updateDepartments");
        operationBinding.getParamsMap().put("deptRow", currentDeptRow);
        Object returnValue = operationBinding.execute();
        if (operationBinding.getErrors().isEmpty()) {
            //No exception, Operation is success
        } else {
            //Exception is thrown from the method, handle it here
            //OperationBinding::getErrors() return list of JboException
            List errorList = operationBinding.getErrors();
            //Alternative path 'on error' go here
        }
    }

AttributeBinding

import oracle.binding.AttributeBinding;
...
...
AttributeBinding departmentName = (AttributeBinding) bindings.get("DepartmentName");


JUCtrlListBinding
To access the list binding from Java, you use the JUCtrlListBinding class, as shown next:

   import oracle.jbo.uicli.binding.JUCtrlListBinding;
   import oracle.jbo.domain.Number;
   ...
   JUCtrlListBinding listBinding = (JUCtrlListBinding) bindings.get("JobId");
   ViewRowImpl selectedListRow = (ViewRowImpl) listBinding.getSelectedValue();
   String jobIdValue = (String) selectedListRow.getAttribute("JobId");
   Number maxSalary = (Number) selectedListRow.getAttribute("MaxSalary");
 
JUCtrlHierBinding
The JUCtrlHierBinding class is used to bind tree, treetable, and table components to the ADF model.

JUCtrlHierBinding hierBinding = (JUCtrlHierBinding)bindings.get("EmployeesView3");
Access Parameter Binding

import oracle.adf.model.binding.DCBindingContainer;
...
...
    public String getPageParamater() {
        DCBindingContainer bindings = (DCBindingContainer)this.getBindings();
        Map map = bindings.getParametersMap();
        String name = map.get("name").toString();
        return null;
    }

Perform Delete and Commit by a single button click

Create a bean named DeleteCommitBean in UI project.

Add a method named onDeleteItem that calls the ADFUtil.invokeEL() helper method to execute the EL expression that you pass in as a parameter. In this case, it will execute a Delete and a Commit. Note that the Delete and Commit methods must be in the Page Definition Bindings for any page that uses them.
    public void onDeleteItem(ActionEvent actionEvent) {
        ADFUtil.invokeEL("#{bindings.Delete.execute}");
        ADFUtil.invokeEL("#{bindings.Commit.execute}");
        System.out.println("Deleted");
    }
Register the bean as managed bean in adfc-config.xml pageflow file.

In the UI, add a button from the Component Palette. Modify the text as Delete and set the ActionListener as
#{FODCommitDeleteBean.onDeleteItem}
You can also click on 'Edit' to modify the same.

Code snippet of invokeEL method in ADFUtil class
public class ADFUtil {

    public static Object invokeEL(String el) {
        return invokeEL(el, new Class[0], new Object[0]);
    }

    public static Object invokeEL(String el, Class[] paramTypes, Object[] params) {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        ELContext elContext = facesContext.getELContext();
        ExpressionFactory expressionFactory = facesContext.getApplication().getExpressionFactory();
        MethodExpression exp = expressionFactory.createMethodExpression(elContext, el, Object.class, paramTypes);
        return exp.invoke(elContext, params);
    }
}

  • FacesContext is a class that contains all of the per-request state information related to the processing of a single JSF request, and the rendering of the corresponding response. It is passed to, and potentially modified by, each phase of the request processing life cycle.
  • ELContext is a class that is used to evaluate an expression.
  • ExpressionFactory is a class that parses a String into a value expression or a method expression for later evaluation.

Pass Parameters inside an ADF Bounded Taskflow

So there is a 'home' page which is displaying the list of locations. User can either click on the location ID to update the record, or create a location by clicking Create button.

First define an input parameter 'Action' in the 'child' taskflow. Set its value as #{pageFlowScope.Action}.

Drag the CreateInsert operation to the task flow diagram to create a method call activity. Change fixed-outcome of the CreateInsert method call activity to done.

Add an expression to the router: #{pageFlowScope.Action == 'New'}



Now in the 'main' taskflow, click on the 'child' taskflow call and in the Property Inspector, set the value of the parameter as #{requestScope.Action}

Add a setPropertyListener property to the Create button. Set the From property to #{'New'}, To property to #{requestScope.Action} and Type as 'action'.

Download the sample application from File Cabinet: PassParaBoundTskflow.rar

ADF - Display value based on selection in LOV

I have a form with 2 fields, Severity and Priority. User will select a value from Severity LOV, and based on the value selected, Priority will get its value.

The problem is when I am saving the form, only the Severity value gets saved in the database, while Priority is set to null, even though I can see the Priority value displayed on the screen while selecting from Severity LOV in the form.

Bind the valueChangeListener property of the LOV with valueChanged method. This is the code of the method:

    public void valueChanged(ValueChangeEvent valueChangeEvent) {
        //The selected value doesn't get updated to the model by the time ValueChangeListener gets 
        //invoked. This will update the model
        JSFUtils.setExpressionValue("#{bindings.Severity.inputValue}", valueChangeEvent.getNewValue());
        Object selectedValue = JSFUtils.resolveExpression("#{bindings.Severity.attributeValue}");
        System.out.println("selectedValue: " + selectedValue.toString());
        String priority = null;
        if (selectedValue.equals("MINOR")) {
            priority = "LOW";
        } else if (selectedValue.equals("FATAL")) {
            priority = "HIGH";
        } else if (selectedValue.equals("MAJOR")) {
            priority = "NORMAL";
        }
        System.out.println("priority: " + priority);
        JSFUtils.setExpressionValue("#{bindings.Priority.inputValue}", priority);
    }

ADF - Programatically Applying and Creating View Criteria

CASE 1: I have already created a view criteria in EmployeeVO, and I want to call it programmatically.
 
public void searchEmployee(Number employeeId) {
        ViewObjectImpl vo = getEmployeesView1();
        ViewCriteria vc = vo.getViewCriteria("findEmployeeVC");
        vo.applyViewCriteria(vc);
        vo.setNamedWhereClauseParam("pEmployeeId", employeeId);
        vo.executeQuery();
    }


CASE 2: I want to create a view criteria dynamically and execute it programmatically.


    public void searchByEmployeeIdEmail(Number employeeId, String email) {
        ViewObjectImpl vo = getEmployeesView2();
        ViewCriteria vc = vo.createViewCriteria();
        ViewCriteriaRow vcRow = vc.createViewCriteriaRow();
        
        vcRow.setAttribute("EmployeeId", employeeId);
        vc.addRow(vcRow);
        vcRow.setAttribute("Email", email);
        vc.addRow(vcRow);
        
        vo.applyViewCriteria(vc);
        vo.executeQuery();
 
 CASE 3: Apply ExecuteQuery() in View Layer 
 
DCBindingContainer bindings2 = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
JUCtrlHierBinding obj = (JUCtrlHierBinding)bindings2.findCtrlBinding("EmployeesEOView1");
ViewObject vo= obj.getViewObject();
vo.setNamedWhereClauseParam("BindEmployeeId",101);
vo.executeQuery(); 
  
Code to check the value in query : 
 
DCBindingContainer dcBindings =(DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
DCIteratorBinding dciter = dcBindings.findIteratorBinding(
EmployeesEOView1Itterator
);
RowSetIterator RowSetI = dciter.getRowSetIterator();
for (Row row : RowSetI.getAllRowsInRange()) {
System.out.println("Row : " + row);
}
RowSetI.closeRowSetIterator();
 
 
 

ADF - Populate ADF Table using managed Bean and DTO

In this use case, we will be building an employee form where the user will enter details and then click on Save. Once the data is saved, the results will be displayed in the table below.



For every field displayed on the form, we need to declare a variable in the managed bean, and create getters setters.
    private String firstName;
    private String lastName;
    private String email;
    private Date hireDate;
    private String jobID;

Now for every inputField, bind the value property with the variable defined. For example, for the First Name field, I have set the value property as #{pageFlowScope.myBean.firstName}.
This is the method defined in the managed bean for the Save button:
 
 public void onClickSave(ActionEvent actionEvent) {
        // Add event code here...
        Map searchValueMap = new HashMap();
        searchValueMap.put(FIRST_NAME, firstName);
        searchValueMap.put(LAST_NAME, lastName);
        searchValueMap.put(EMAIL, email);
        searchValueMap.put(HIRE_DATE, hireDate);
        searchValueMap.put(JOB_ID, jobID);

        Map parameters = new HashMap();
        parameters.put("params", searchValueMap);

        BindingContainer bindings = getBindings();
        OperationBinding operationBinding =
            bindings.getOperationBinding("saveEmployee");
        operationBinding.getParamsMap().putAll(parameters);
        emplist = (List)operationBinding.execute();

        AdfFacesContext.getCurrentInstance().addPartialTarget(empTable);
    }

This is from the Application module:


    public List saveEmployee(Map params) { 
 
        ViewObjectImpl vo = getEmployeesView1();
        ViewRowImpl vor = (ViewRowImpl)vo.createRow();
        getEmployeesView1().insertRow(vor);
        //vor.setAttribute("EmployeeId", params.get("employeeID"));
        vor.setAttribute("FirstName", params.get("firstName"));
        vor.setAttribute("LastName", params.get("lastName"));
        vor.setAttribute("Email", params.get("email"));
        vor.setAttribute("HireDate", params.get("hireDate"));
        vor.setAttribute("JobId", params.get("jobID"));
        vor.getApplicationModule().getTransaction().commit();

        vo.executeQuery();
        
        List employeeList = null;
        EmployeeDTO employeeDTO = null;
        
        RowSet rowSet = vo.getRowSet();
        Row row = null;
        if (null != rowSet) {
            employeeList = new ArrayList();
            row = rowSet.first();
            while (null != row) {
                employeeDTO = getEmployeeDTOFromRow(row);
                employeeList.add(employeeDTO);
                row = rowSet.next();
            }
        }
        return employeeList;
    }
    
    private EmployeeDTO getEmployeeDTOFromRow(Row row) {
        EmployeeDTO employeeDTO = new EmployeeDTO();
        employeeDTO.setEmployeeID((Number)row.getAttribute("EmployeeId"));
        employeeDTO.setFirstName((String)row.getAttribute("FirstName"));
        employeeDTO.setLastName((String)row.getAttribute("LastName"));
        employeeDTO.setEmail((String)row.getAttribute("Email"));
        employeeDTO.setHireDate((Date)row.getAttribute("HireDate"));
        employeeDTO.setJobID((String)row.getAttribute("JobId"));
        return employeeDTO;
    }

For the table, I have set the value property as #{pageFlowScope.myBean.emplist} and binding property as #{pageFlowScope.myBean.empTable}. Getters and setters are created for both:
 
    private RichTable empTable;

    private List emplist;

Delete Selected Rows from Table with Select all option Boolean check box - ADF with POP up

Delete  Selected Rows from Table with Select all option Boolean check box



This is the Java code in the Bean:
package demo.view;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.faces.event.ValueChangeEvent;

import oracle.adf.model.BindingContext;
import oracle.adf.model.binding.DCBindingContainer;
import oracle.adf.model.binding.DCIteratorBinding;
import oracle.adf.view.rich.event.DialogEvent;
import oracle.adf.view.rich.event.PopupCanceledEvent;
import oracle.adf.view.rich.event.PopupFetchEvent;

import oracle.binding.OperationBinding;

import oracle.jbo.Row;
import oracle.jbo.RowSetIterator;


public class employeeOperations {
    public employeeOperations() {
    }

    public void deleteMultiple(ActionEvent actionEvent) {
        DCBindingContainer bindings = getBindings();
        DCIteratorBinding iteratorBinding = bindings.findIteratorBinding("EmployeeVO1Iterator");

        Row[] r = iteratorBinding.getViewObject().getFilteredRows("SelectBox", true);
        for (int i = 0; i < r.length; i++) {
            r[i].remove();
        }

        OperationBinding operationBinding = bindings.getOperationBinding("Commit");
        operationBinding.execute();
        if (!operationBinding.getErrors().isEmpty()) {
            addFacesMessage(FacesMessage.SEVERITY_ERROR, "Error in Deleting Records");

        } else {
            addFacesMessage(FacesMessage.SEVERITY_INFO, "Records Deleted Succesfully");
        }
    }

    public void dialogListener(DialogEvent dialogEvent) {
        if (dialogEvent.getOutcome().name().equals("ok")) {
            DCBindingContainer bindings = getBindings();
            OperationBinding method = bindings.getOperationBinding("Commit");
            method.execute();
        } else if (dialogEvent.getOutcome().name().equals("cancel")) {
            DCBindingContainer bindings = getBindings();
            OperationBinding method = bindings.getOperationBinding("Rollback");
            method.execute();
        }
        System.out.println("dialogListener Executed");
    }

    public static void addFacesMessage(FacesMessage.Severity severity, String message) {
        FacesMessage fm = new FacesMessage(severity, message, null);
        FacesContext.getCurrentInstance().addMessage(null, fm);
    }

    public DCBindingContainer getBindings() {
        return (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
    }

    public void popupCancelListener(PopupCanceledEvent popupCanceledEvent) {
        DCBindingContainer bindings = getBindings();
        OperationBinding method = bindings.getOperationBinding("Rollback");
        method.execute();
        System.out.println("popupCancelListener Executed");
    }

    public void popupFetchListener(PopupFetchEvent popupFetchEvent) {
        DCBindingContainer bindings = getBindings();
        OperationBinding method = bindings.getOperationBinding("CreateInsert");
        method.execute();
        System.out.println("popupFetchListener Executed");
    }

    public void selectAllRows(ValueChangeEvent valueChangeEvent) {
        DCBindingContainer bindings = getBindings();
        DCIteratorBinding it = bindings.findIteratorBinding("EmployeeVO1Iterator");
        RowSetIterator rit = it.getRowSetIterator();
        //rit.reset();
        if (valueChangeEvent.getNewValue() != null) {
            Boolean selectAll = Boolean.parseBoolean(valueChangeEvent.getNewValue().toString());
            if (rit.first() != null) {
                Row r = rit.first();
                r.setAttribute("SelectBox", selectAll);
            }
            while (rit.hasNext()) {
                Row r = rit.next();
                if (r != null) {
                    r.setAttribute("SelectBox", selectAll);
                }
            }
        }
    }
}
This is the code in the Main.jspx for the checkBox created on the header:
<f:facet name="header">
    <af:selectbooleancheckbox autosubmit="true" id="sbc2" simple="true" valuechangelistener="#{HRBean.selectAllRows}">
</af:selectbooleancheckbox></f:facet>

Create a row at the end of an ADF table

 
import oracle.adf.model.BindingContext;
import oracle.binding.BindingContainer;
import oracle.jbo.NavigatableRowIterator;
import oracle.jbo.Row;
import oracle.jbo.uicli.binding.JUCtrlHierBinding;
import oracle.adf.model.binding.DCIteratorBinding;

    public String cb1_action() {
        // Add event code here...
        BindingContainer bc = BindingContext.getCurrent().getCurrentBindingsEntry();
        JUCtrlHierBinding hierBinding = (JUCtrlHierBinding)bc.get("EmployeesView3");
        DCIteratorBinding dciter = hierBinding.getDCIteratorBinding();
        NavigatableRowIterator nav = dciter.getNavigatableRowIterator();
        Row newRow = nav.createRow();
        newRow.setNewRowState(Row.STATUS_INITIALIZED);
        Row lastRow = nav.last();
        int lastRowIndex = nav.getRangeIndexOf(lastRow);
        nav.insertRowAtRangeIndex(lastRowIndex + 1, newRow);
        dciter.setCurrentRowWithKey(newRow.getKey().toStringFormat(true));
        return null;
    }
 
 
Now some concepts about inserting row in different places of the table:

1. User wants to create a new row as the first row of the table. In that case

newRow.setNewRowState(Row.STATUS_INITIALIZED);
nav.insertRowAtRangeIndex(0, newRow);
dciter.setCurrentRowWithKey(newRow.getKey().toStringFormat(true));
 
2. User wants to create a new row before the current selected row

newRow.setNewRowState(Row.STATUS_INITIALIZED);
nav.insertRow(newRow);
dciter.setCurrentRowWithKey(newRow.getKey().toStringFormat(true));
 
3. User wants to create a new row after the current selected row

newRow.setNewRowState(Row.STATUS_INITIALIZED);
Row currentRow = nav.getCurrentRow();
int currentRowIndex = nav.getRangeIndexOf(currentRow);
nav.insertRowAtRangeIndex(currentRowIndex+1, newRow);
dciter.setCurrentRowWithKey(newRow.getKey().toStringFormat(true));
Infact if the CreateInsert operation is dragged into the page and created as a button, the 2nd point would have been achieved.

If you set the EditingMode as 'clickToEdit', the rows will appear as read-only. Once the user clicks on a particular row, he/she can edit the row. But make sure that the row selection of the table component must be set as Single.

Difference between AutoSubmit and PartialSubmit
autoSubmit: Related to an input component (such as inputText and selectOneChoice) or a table select component (such as tableSelectOne). The component automatically submits the form it is enclosed in
partialSubmit: Releated to a command component. The page partially submits when the button or link is clicked.

If a component has its immediate attribute set to true, then the validation, conversion, and events associated with the component are processed during this phase.

setNewRowState
This method should be used to create a row and then to mark it temporary (STATUS_INITIALIZED) so that the user can use the created Row to fill UIs like Table UIs with valid default values for rows. Then when the Row values are updated, UIs should once again call this method to turn the Row into new (STATUS_NEW) state before any setAttribute calls on the Row, so that the changes are validated and posted.

Get Row Count in Application Module - ADF Java code

 Get Row Count in Application Module - ADF Java code
 
public intgetRowCount() {

ViewObject vo = this.getBillableLineNumVo1();
vo.executeQuery();
RowSetIterator rsIterator = vo.createRowSetIterator(null);
rsIterator.reset();

 while (rsIterator.hasNext()) {
 Row row = rsIterator.next();
 val = ((BigDecimal)row.getAttribute("Attribute1")).longValue();
 System.out.println(" Count from the VO is :::: " +
 row.getAttributeCount());
 }

 rsIterator.closeRowSetIterator();
return val;

}

Clearing Data Control values - ADF Custom Java code

Clearing Data Control values -  ADF Custom Java code




public void clearDataControl(){

DCBindingContainer bindings1 = (DCBindingContainer) BindingContext.getCurrent().getCurrentBindingsEntry();
DCIteratorBinding dcItBindings1 = bindings1.findIteratorBinding("IteratorName");
RowSetIterator iter = dcItBindings1.getRowSetIterator();
iter.reset();
Row[] rows = iter.getAllRowsInRange();
for (int r = 1; r < rows.length; r++){
if (rows[r] != null)
rows[r].remove();
}
}

Reading Values From Resource Bundle ADF - Java Code

Reading Values From Resource Bundle ADF - Java Code


ResourceBundle res = ResourceBundle.getBundle("Resource_FileName");
String value=res.getString(" keyOne");

Operator Binding in ADF - Call Client method in BC from View


 
Operator Binding in ADF -  Call Client method in BC from View


          

Calling Client method from ViewControllerProject 
 
            BindingContext bcx = BindingContext.getCurrent();
            DCBindingContainer bc = (DCBindingContainer)bcx.getCurrentBindingsEntry();
            
            // Method Name 
            OperationBinding opb = (OperationBinding)bc.getOperationBinding("TestMethod");
           
             //  Arguments in method
             opb.getParamsMap().put("arg", "Moorthi");
             opb.invoke();



AM Client Method :


    public void TestMethod( String arg){
        // Add your logic
    }
 


Client Method exposed in data control