Tuesday, 15 March 2016

ADF DATA CONTROL OPERATIONS

For the application module, we have the default operations defined. They are the Commit and Rollback operations.


The operations available for the view object collection are as follows:


Create:
This operation is available to create a new record for the table component. The newly created record will not be inserted and is not displayed in the UI for a table component. For a form-based component, this method will create a new record and will display the information.
Create Insert:
This operation will create a new record and will also insert a blank record if there is no default value assigned for the attributes of the record. The newly created row is displayed in the UI for the table component.
Create with parameters:
This method will allow the user to create a new record with some parameters, and the values passed as parameters will be predefined for the created row.
Delete: This operation is used to delete the current row from the view Object collection.
Execute: This operation will execute and refresh the current collection.
Find: To find a specific record in the collection object.
First: This method sets the current row so that the first row is shown to the user.
Last: This operation is used to set the last row of the view object collection as the current row.
Next: This operation is used to refer to the next row in the collection as the current row.
Next Set: This operation is used to move to the next set in the collection.
Previous: This method is used to set the previous record as the current row.
Previous Set: This method is used to move to the previous set in the view object collection.
removeRowWithKey: The key value is provided for this operation to remove the row matching the corresponding key.
setCurrentRowWithKey: The current row in the collection is set to the row matching the corresponding key passed using this operation.
setCurrentRowWithKeyValue: This operation will set the row to the matching key value.


Thursday, 10 March 2016

SetPropertyListener vs. SetActionListener


The af:setPropertyListener and af:SetActionListener components are located under the Operations section of the ADF Faces components panel in the Oracle JDeveloper Component Palette.

They are used to write objects into memory or a managed bean property. While both listeners appear to have identical functionality, they are actually different.

SetActionListener Vs. SetPropertyListener

The af:SetActionListener responds to action events only, such as a button or link mouse click. In contrast, the af:setPropertyListener responds to events such as calendar, value change, disclosure, focus, launch, poll, range change, return, row disclosure, dialog, launch popup, popup fetch, query, query operation, region navigation, and return popup.

The SetPropertyListener is new in Oracle JDeveloper 11g and should be used instead of the SetActionListener, which is included in Oracle JDeveloper 11g for backward compatibility.

How to Pass Values Between Pages

Frequent developer requirement is to pass data from one page to the next, which can be done through memory scope attributes.
To pass the value of the selected DepartmentId attribute from one page to the next, you use the SetPropertyListener as shown next:

<af:setPropertyListener
  from="#{bindings.DepartmentId.inputValue}"
   to="#{requestScope.deptId}" type="action"/>


If the SetPropertyListener component is added to a button, when the button is clicked, the input value of the DepartmentId attribute binding in the pageDefinition.xml file of the current page is read and stored in the deptId attribute of the requestScope. The deptId attribute is automatically created if it doesn’t exist. The attribute can be accessed from the navigated page using Expression Language or Java.

NOTE
Though we referenced the PageDef file in the explanation above,at runtime values are read from the binding container, which is the object instance created from the pageDefinition.xml file.

NOTE

The ADF Business Component business service is a smart layer that remembers the selected row when navigating from one page to another that uses the same view object through the ADF binding layer. In this case, you don’t need to pass data between pages.

SelectOneChoice ListofValues

In Select One Choice we can creat a list of values by
1.Model Driven.: Means the list coming from the database
2.Custom List:Means through a managed Bean we will add a list.



  1.We have to create a variable of type "JAVA.UTILL.LIST" and generate getters and setter for that variable.
  2.now that list should be a specific type of "SelectItem."
  3."javax.faces.model.SelectItem" is supported by af:SelectOneChoce
  4.List<SelectItem> variable_name;

NOTE: In order to create a list of values we have to create a object of list type
      eg: List<String> variable_name= new ArrayList<>();
          list.add("a");
          list.add("b");
          list.add("c");
  5.We have to add values in the list through getter method...

    public List<SelectItem> getvariable_name()
    {

     if(variable_name==null)
     {
 
      variable_name=new ArrayList<SelectItem>();  // here we are creating a object
      variable_name.add(new SelectItem("i1","Item 1"));
      variable_name.add(new SelectItem("i2","Item 2"));
      variable_name.add(new SelectItem("i3","Item 3"));

     }
     }

Duplicate cpx File Found

Error: Duplicate cpx file found?
 It comes when we  trying to use a region from an ADF Library to another project.

Theory:
By default JDeveloper will create a DataBindings.cpx file whenver we drag and drop datacontrol object on to a jsf page.
We will Get "Duplicate cpx file found" when our application and the imported ADF Library also contains "DataBindings.cpx"
So when this happens our application uses only first one that is found in the classpath and ignores othrer.

Solution:
Change the name of our local consming application (using refractiong) and then reimport the library.

GET A ATTRIBUTE FROM A ROW OF VIEW OBJECT PROGRAMMACTICALLY?

1.First Get the ViewObject
2.Second use The Row interface
3.Get the row at index
3.Use getAttriubte()  method. and cast to toString()


1.ViewObjectImpl view = this.getSponsorVO1();
//getSponsorVo1(){ has findViewObject("SponsorVO1") method}
    public SponsorVOImpl getSponsorVO1()
{
        return (SponsorVOImpl)findViewObject("SponsorVO1");// Casting to Imp as we are using ViewObjectIMpl
}
2.Row row = view.getRowAtRangeIndex(0);
3.String sponsorId= row.getAttribute("SponsorId").toString();

Call ViewCriteria Programmactically




1.First Call viewObject
2.Then Call viewCriteria by using getViewCriteria();

ViewObjectIMpl vo=this.getSomeViewObject();
ViewCriteria vc=vo.getViewCriteria("Crietria name");

-APPlyViewCriteria //viewobject refernce
vo.applyViewCriteriea(vc);
-ResetViewCriteria  // viewcrietria refernce
vc.resetCriteria();
-RemoveViewCriteria. // viewobject refernce
Vo.removeViewCriteria("Criteria name");