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");

Wednesday, 9 March 2016

Get value From PageFlowScope Programmactically

AdfFacesContext.getCurrentInstance().getPageFlowScope().get("ntwkID")

Partial Submit Vs Auto Submit

Partial Submit 
ADF Faces adds the concept of partial form submit to JavaServer Faces 1.2 and beyond. A partial submit actually is a form submit that does not require a page refresh and only updates components in the view that are referenced from the command component PartialTriggers property. Another option for refreshing a component in response to a partial submit is callAdfContext.getCurrentInstance.addPartialTarget(component_instance_handle_goes_here)in a managed bean. If a form contains required fields that the user left empty invoking the partial submit, then errors are shown for each of the field as the full form gets submitted. 
Autosubmit
An input component that has its autosubmit property set to true also performs a partial submit of the form. However, this time it doesn't submit the entire form but only the component that triggers the submit plus components referenced it in theirPartialTriggers property.
For example, consider a form that has three input fields inpAinpB and inpC with autosubmit=true set on inpA andrequired=true set on inpB and inpC.
use case 1: Running the view, entering data into inpA and then tabbing out of the field will submit the content for inpA but not for inpB and inpC. Further more, none of the required field settings on inpB and inpC causes an error.
use case 2: You change the configuration of inpC and set its PartialTriggers property to point to the ID of componentinpA. When rerunning the sample, entering a value into inpA and tabbing out of the field will now submit the inpA and inpC fields and thus show an error for the missing required value on inpC.
Internally, using autosubmit=true on an input component sets the event root to just this field, which good to have in case of dependent field validation or behavior. The event root can extended to include other components by using the Partial Triggers property on these components to point to the input field that has autosubmit=true defined.
PartialSubmit vs. AutoSubmit
Partial submit set on a command component submits the whole form and leaves it to the developer to decide which UI component is refreshed in response. Client side required field validation (as well as the server side equivalent) is not disabled by executed in this scenario. Setting immediate=true on the command item to skip validation doesn't help as it would also skip the model update.
Auto submit is a functionality on the input components and also performs a partial form submit. However, in addition an event root is defined that narrows the scope for the submitted data and thus the components that are validated on the request.
____________________________________________________________________________________________
______________________________________________
PARTIALSUBMIT
Default Value: false
whether the action should be done through a partial page submit or not. Default is false: no partial page submit; the full page will be refreshed. When set to true, the full page will not be refreshed. To re-render specific components on your page in response to the partial page submit, you have to tell ADF Faces. The easiest way to do this is with the partialTriggers attribute.

isPartialSubmit
public final boolean isPartialSubmit()
Gets whether the action should be done through a partial page submit or not. Default is false: no partial page submit; the full page will be refreshed. When set to true, the full page will not be refreshed. To re-render specific components on your page in response to the partial page submit, you have to tell ADF Faces. The easiest way to do this is with the partialTriggers attribute.
Returns:
the new partialSubmit value

setPartialSubmit

public final void setPartialSubmit(boolean partialSubmit)

Sets whether the action should be done through a partial page submit or not. Default is false: no partial page submit; the full page will be refreshed. When set to true, the full page will not be refreshed. To re-render specific components on your page in response to the partial page submit, you have to tell ADF Faces. The easiest way to do this is with the partialTriggers attribute.
Parameters:
partialSubmit - the new partialSubmit value

AUTOSUBMIT

Default Value: false
autosubmit="true"
an attribute which if set to TRUE on a form element, the component will automatically submit when an appropriate action takes place (a click, text change, etc.). 
Since autoSubmit is a partial submit, also submitted and re-rendered are any other components with partialTriggers pointing to this component.

isAutoSubmit

public final boolean isAutoSubmit()
Gets an attribute which if set to TRUE on a form element, the component will automatically submit when an appropriate action takes place (a click, text change, etc.). Since autoSubmit is a partial submit, also submitted and re-rendered are any other components with partialTriggers pointing to this component.
Returns:
the new autoSubmit value

setAutoSubmit

public final void setAutoSubmit(boolean autoSubmit)
Sets an attribute which if set to TRUE on a form element, the component will automatically submit when an appropriate action takes place (a click, text change, etc.). Since autoSubmit is a partial submit, also submitted and re-rendered are any other components with partialTriggers pointing to this component.
Parameters:
autoSubmit - the new autoSubmit value
________________________________________________________________________________________________________________________________________
autoSubmit: Related to an input component (such as inputText and selectOneChoice) or a table select component (such 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
________________________________________________________________________________________________________________________________________