Tuesday, July 22, 2014

Select Many Choice use in ADF

Hi All, if we want to select multiple values from the list box then we will make use of inbuilt component "af:selectmanychoicebox" in ADF. follow these steps to use this component.

Step1: Create view object for example I have created "DepartmentsVO"

Step2: make an attribute as lov from "DepartmentsVO"

Step3:  create one jspx page and add List binding in page definition as shown below




Step 4: from component pallete select "Select Many Choice component" and it will ask for bindings add bindings like below and click on ok




Step 5: Run the page you will get the output like this


Friday, July 18, 2014

Adding Validation to the Criteria in ADF

Hello Guys if you want to add validation to the input text fields of the Criteria please follow the steps.

Step1: Create a view Criteria as shown below

Step2:

Drop this named criteria from data controls to a page as Query Panel





Step3:

Drop the View Object as form on the same page

Step4: add Partial Target of the form to Criteria




Step5: Select af:Query Component in Structure window and change the query listner property from Property Inspector as shown below(Default query Listner value is: #{bindings.EmployeesEOViewCriteriaQuery.processQuery} ) save this value which needs to be used in bean class




Step6:

write the following code in the bean class:

package com.test.beans;

import com.mobile.model.TestAMImpl;

import javax.el.ELContext;
import javax.el.ExpressionFactory;
import javax.el.MethodExpression;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

import oracle.adf.model.BindingContext;
import oracle.adf.model.binding.DCDataControl;
import oracle.adf.model.binding.DCIteratorBinding;
import oracle.adf.view.rich.event.QueryEvent;

import oracle.binding.BindingContainer;

import oracle.jbo.ApplicationModule;
import oracle.jbo.server.ViewObjectImpl;

public class FormValidate1 {
    public FormValidate1() {
    }

    public void customQueryListner(QueryEvent queryEvent) {     // Add event code here...
       
       String fname = null;
        String lname = null;
        BindingContext ctx = BindingContext.getCurrent();
        BindingContainer cont = ctx.getCurrentBindingsEntry();
        DCIteratorBinding dci = (DCIteratorBinding) cont.get("EmployeesEOView1Iterator");
        ApplicationModule am  = dci.getDataControl().getApplicationModule();
        //ApplicationModule am  = dci.getDataControl().
//        cont.ge
       //  ApplicationModule am  = dci.geta
        DCDataControl dc = ctx.findDataControl("TestAMDataControl");
        TestAMImpl ta =(TestAMImpl) dc.getApplicationModule();
       
        ViewObjectImpl voi = (ViewObjectImpl)dci.getViewObject();
        fname = (String)voi.getNamedWhereClauseParam("bFirstName");
        lname = (String)voi.getNamedWhereClauseParam("bLastName");
        if(fname.length() >4) {
        FacesContext.getCurrentInstance().addMessage(null,new FacesMessage("Name should not be lessthan 4 charecters"));
        }
        else if(am.getTransaction().isDirty()) {
            FacesContext.getCurrentInstance().addMessage(null,new FacesMessage("Please Save the changes or Undo Them"));
        }
       
        else{
           
         String el = "#{bindings.EmployeesEOViewCriteriaQuery.processQuery}";
            invokeEL(el, new Class[]{QueryEvent.class}, new Object[]{queryEvent});
           // invokeEL(el, null,  new Object[]{queryEvent});
        }
       
       
    }
   
   
    public static Object invokeEL(String el,Class[] paramtypes, Object[] params) {
        FacesContext cont = FacesContext.getCurrentInstance();
        ELContext elcont =  cont.getELContext();
        ExpressionFactory ef = cont.getApplication().getExpressionFactory();
        MethodExpression exp = ef.createMethodExpression(elcont, el, Object.class, paramtypes);
        return exp.invoke(elcont, params);
    }
}

Step7:
Run the application and give charecters for firstname more than 4 you will get error message.









Wednesday, June 25, 2014

ADF Logging

Hi Guys today I am going to implement adf logging.

To create please follow the steps.

1. Create a java class and import "oracle.adf.share.logging.ADFLogger"

2. get the instance of Logger object.

public static ADFLogger logger = ADFLogger.createADFLogger(LoggerBean.class);\

3. write a java method and add some information to the logger object.

    public String logging() {
        logger.info("this is from logging bean");
        // Add event code here...
        return null;
    }

4. Create a jspx page and call this method from  the page by using action or what ever you want.



5. Logging Configuration in Oracle jDeveloper.

5.1. Keep the Server in running mode and go to the java class and select Actions from log window and select Configure Oracle Diagnostic Logging.


5.2 In Oracle Diagnostics Logging Configuration Click on + symbol and select Add Persistent Logger.

give the package name to which you want to give logging and click on OK


5.3. Go to Structure window and copy & paste one log_handler and change the name.


5.4. Goto Source Tab and change the file location i.e, path for this log_handler.

ex. <property name='path' value='${domain.home}/servers/${weblogic.Name}/logs/rajuOwn.log'/>

5.5 Go to Overview Tab and in Handler Declarations click on + Symbol. and select the log_handler (raju_hanlder) as we have created in the step 5.3.



6. Now run the jspx page and click on button you will get a file with the name "rajuOwn.log" at the location:

C:\Users\User Name\AppData\Roaming\JDeveloper\system11.1.1.6.38.61.92\DefaultDomain\servers\DefaultServer\logs

if you have any doubts feel free to reach me..

njy learning adf.










Monday, June 9, 2014

Populating a message after a record inserted or deleted from database

Hi All, if we want to show a message after inserting a record for example. we want to show a message after inserting a student record in database "Student Created Successfully" to the user then follow these steps.

Step1:

add JSF1.2 jar to the project by right clicking on model of the current project >> Project Properties >> Libraries and Tag Libraries >> Add Library >> JSF 1.2 >> Click on OK



Step2:

Generate Impl class of Entity Object

Step3:

import following classes

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

Step4:

write following lines of code in doDML() method of impl class of entity object

        FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, null, "Student has been created");

        FacesContext.getCurrentInstance().addMessage(null, msg);


it will show you the popup message like this:




Thats it....

Thursday, June 5, 2014

how to create a new empty record or showing a table with editable values of an View Object in ADF

Hii All, if we drag and drop an View Object Data Control as a form. If that View Object referring to a table dont have any data then it will show us an fields but not the editable fields to enter the values. or it will show the first record of the data base.

For Ex. for creating a student record showing the values is not required. we have to show the form in editable mode. for this we have two approaches.

Approach1:

1. Drag and Drop Data Control as form

2. Go to Bindings tab

3. Create new binding

4.select binding type "Action" >> select data control >> select operation as Create Insert >> click on ok.in



5. in executable s create new executable by clicking on + symbol .>> select insert item as "invokeAction" select any id value and binds to "Create Insert".



6. Click on Edit Executable >> in common properties select common >> Select Refresh as "Render Model" click on finish.



7. now you run the page the page will generate the fields in editable format.


Approach 2:

1. Create a JSF(i.e, jspx) page with view object as form

2. Create Task flow

3. In the task flow add action of data control "Create Insert" as view activity and make it as default activity

4. drag and drop jsf page

5. Create control flow between default activity and jsf page.

6. Run the task flow you will get a form with editable fields.

ennjoy learning adf


Wednesday, June 4, 2014

how to change default browser to another browser in oracle ADF (jDeveloper)

Hi All,

To change default browser from Internet Explorer to Mozilla firefox please follow the steps.

Steps.

1.Tools >> Preferences >> Web Browser & Proxy >> In Browse Command Line select the mozilla.exe file from the directory.

For ex: C:\Program Files (x86)\Mozilla Firefox\firefox.exe

enjoy......

Hide Query By Example of PanelCollection on page load

Hi All, If there is a table with filterable is true. If you want to display QueryByExample then surround this table with panelCollection....