Pages

Thursday, January 30, 2014

ADF Create , Delete , Rows in View Object


There are many ways to to create a new Row for  the View Object

Firstly make sure that the View object can be Updated ( Based on Entity)

1- Operations

Operation Like Create , CreateInsert , CreateWithParams

here you can simply drag and drop from DataControl to Your Page or You can execute the operation in the code
for Example  :

============================================================

  ViewObject vo = ADFUtils.getAm().getCountriesView1();
      BindingContainer bindings = getBindings();


// Create Operation


    OperationBinding opCreate = bindings.getOperationBinding("Create");


// Commit Operation


    OperationBinding opCommit = bindings.getOperationBinding("Commit");


// Delete Operation


    OperationBinding opDelete = bindings.getOperationBinding("Delete");



  // Create The Row


  opCreate.execute();


// Create  the RowImpl  from Java Tab in VO

// this will be The Created Row


  CountriesViewRowImpl row =                       (CountriesViewRowImpl)vo.getCurrentRow();


//Set The Data


  row.setCountryId("105");


  row.setCountryName("Abcd");


  row.setRegionId(100);



// Save - Commit All Updates 


opCommit.execute();

// Delete current row 

opDelete.execute();


============================================================


2- Coding

   ViewObject vo = ADFUtils.getAm().getCountriesView1();

      BindingContainer bindings = getBindings();



        
        Row newRow = vo.createRow();
        
        newRow.setAttribute("CountryId", "105"); 
  
        newRow.setAttribute("CountryName", "Abcd"); 
  
        vo.insertRow(newRow);


// Commit Operation


    OperationBinding opCommit = bindings.getOperationBinding("Commit");


// Save - Commit All Updates 


opCommit.execute();


// Delete current row 


 vo.getCurrentRow().remove();



Tuesday, January 28, 2014

How Send Data Through Process ,Session ,PageFlow Scope ?

Sometimes we need to save data in the backing bean to use it later.
So you need to store this value in a scope


Set in UserData
        ADFUtils.getAm().getSession().getUserData().put("CustomerName", "ADAM");

Get : 

     ADFUtils.getAm().getSession().getUserData().get("CustomerName");


Groovy adf.userSession.userData.CustomerName


Set in Process Scope

 AdfFacesContext.getCurrentInstance().getProcessScope().put("CustomerName", "ADAM");
   
Get : 
      AdfFacesContext.getCurrentInstance().getProcessScope().get("CustomerName");




Set in PageFlow Scope

    AdfFacesContext.getCurrentInstance().getPageFlowScope().put("CustomerName","ADAM"); 

Get : 
    AdfFacesContext.getCurrentInstance().getPageFlowScope().get("CustomerName"); 




Monday, January 27, 2014

List of Value using Tree and ForEach

List of Value using Tree and ForEach

 Using  Tree and ForEach

we will use Departments Table ( Id , Name, Location ... )


we need to add a tree in Binding for the Page.


Click Ok then  you will see this popup , Click add then choose the ViewObject that you want to use
in our case wee need DepartmentsView .




Then add the rule as below

then choose the Attributes that you want , in our case we need DepartmentId and DepartmentName

Then click Ok .
now you can see Tree in the Bindings and its name DepartmentsView1

Now You can use the Tree in For Each

and here is the Code for ForEach
________________________________________________________

<af:selectOneChoice label="Department" autoSubmit="true"
        valueChangeListener="#{LovMB.lovTreeChangeListner}">
     <af:forEach items="#{bindings.DepartmentsView1.rangeSet}"          var="row">

        <f:selectItem itemLabel="#{row.DepartmentName}" itemValue="#{row.DepartmentId}"/>

     </af:forEach>
 </af:selectOneChoice>
________________________________________________________


and this the code for ValueChangeListner



The final result will be