Please disable your adblock and script blockers to view this page

Search this blog

Showing posts with label CreateInsert. Show all posts
Showing posts with label CreateInsert. Show all posts

Sunday 19 January 2014

Creating new object in list (af:inputListOfValues) using 'createPopupId' feature- ADF 11g & 12c

Hello All ,
This post is about a good feature provided with inputListOfValues in ADF .
inputListOfValues is used where large and complex data is populated in list, this component supports search in list values
Suppose on opening list values you want to add one more value in list generally to do that you will  close the list and add a value in source table then again open list but this feature provide instant creation of list values

this functionality can be achieved in Combo Box with List of Values using customActions facet, i have posted about it
Create new look up data using List of Values (LOVs) in Oracle ADF

so this time it is about  inputListOfValues, see the steps to do

  • Created a fusion web application and business components  using Departments and Employees table of HR Schema

  • now i have created list of values on DepartmentId of Employees ViewObject referenced from Department ViewObject, display type is Input Text with List of Values

  •  drop Employees VO on page and run, it looks like this

  • Now i have dropped a popup on page and to create new value in list, i have dropped form of Departments ViewObject and a link to create it on dialog inside popup

  • select list of values component (Employee VO) in structure window and go to property inspector and set popUp id in a property called 'createPopupId'
  • After setting 'createPopupId' ,on running a commandToolbarButton appears in the LOV popup dialog box with a icon, this button's action triggers custom popUp (i have added before)
        on clicking on this icon-

  •  on create link i have just called createInsert for Departments ViewObject and on dialogListener , Execute

  • import oracle.adf.model.BindingContext;
    import oracle.binding.BindingContainer;
    import oracle.binding.OperationBinding;
        /**Method to get Bindings of current page
         * @return
        public BindingContainer getBindings(){
            return BindingContext.getCurrent().getCurrentBindingsEntry();
        /**Method to execute OperationBinding
         * @param operation
         * @return
        public OperationBinding executeOperation(String operation){
            return getBindings().getOperationBinding(operation);
        /**Method to create new Department
         * @param actionEvent
        public void createDeptAction(ActionEvent actionEvent) {

  • now created a new department using 'create' link and you can see value is appeared in list values

 Cheers :-)

Monday 8 July 2013

Create new look up data using List of Values (LOVs) in Oracle ADF

While working on project , I have seen such type of LOV that have a option of create Lov Value at selection time, this is quite good, as if desired value is not available in list then user can create on that time.

This type of list looks like this

It means if there is no company available in list you need not to go on Company form, user can create it directly from here.
Doing this in ADF is quite simple , in this tutorial i am taking example of Oracle default HR schema (Employees and Departments) table-
Implementation Steps-
  • Create business components from Department and Employees tabl

  •  Now create LOV on DepartmentId of employees ViewObject from Department VO

  • Go to UI Hints tab of LOV and select Combo Box with List of Values

  •  Now drag fields of Employee from DataControl to page as form
  •  Select Department Id Lov and go to structure window, and drop a link in customActions facet of  af:inputComboboxListOfValues
  • Now drag a popup on page and drag Department VO on af:dialog as form to create new department. and other things are same as normal form

  • Bind this popup to bean and create a ActionListener on the link inside facet to invoke createInsert of department table

  • package lookup.view.bean;
    import javax.faces.context.FacesContext;
    import javax.faces.event.ActionEvent;
    import oracle.adf.model.BindingContext;
    import oracle.binding.BindingContainer;
    import oracle.binding.OperationBinding;
    import org.apache.myfaces.trinidad.render.ExtendedRenderKitService;
    import org.apache.myfaces.trinidad.util.Service;
    public class LookupDataBean implements Serializable {
        private RichPopup deptPopUpBind;
        public LookupDataBean() {
        public BindingContainer getBindings() {
            return BindingContext.getCurrent().getCurrentBindingsEntry();
        private void showPopup(RichPopup pop, boolean visible) {
            try {
                FacesContext context = FacesContext.getCurrentInstance();
                if (context != null && pop != null) {
                    String popupId = pop.getClientId(context);
                    if (popupId != null) {
                        StringBuilder script = new StringBuilder();
                        script.append("var popup = AdfPage.PAGE.findComponent('").append(popupId).append("'); ");
                        if (visible) {
                            script.append("if (!popup.isPopupVisible()) { ").append(";}");
                        } else {
                            script.append("if (popup.isPopupVisible()) { ").append("popup.hide();}");
                        ExtendedRenderKitService erks =
                            Service.getService(context.getRenderKit(), ExtendedRenderKitService.class);
                        erks.addScript(context, script.toString());
            } catch (Exception e) {
                throw new RuntimeException(e);
        public void createDept(ActionEvent actionEvent) {
            BindingContainer bindings = getBindings();
            OperationBinding ob = bindings.getOperationBinding("CreateInsert");
            showPopup(deptPopUpBind, true);
        public void DeptDialogListener(DialogEvent dialogEvent) {
            FacesContext fct = FacesContext.getCurrentInstance();
            if (dialogEvent.getOutcome().name().equals("ok")) {
                BindingContainer bindings = getBindings();
                OperationBinding ob = bindings.getOperationBinding("Commit");
        public void setDeptPopUpBind(RichPopup deptPopUpBind) {
            this.deptPopUpBind = deptPopUpBind;
        public RichPopup getDeptPopUpBind() {
            return deptPopUpBind;

  • Now run this application and click on Lov of DepartmentId, you will see your link there to create Department

  • Now see that how many departments are listed currently in LOV

  • Now click on Add Department link and add a department
  •  Again see the listed departments- Oracle ADF Tutorial is added in now list
 this is how you can use this beautiful feature in your LOV-
Sample ADF Application- Download

Tuesday 11 December 2012

Insert New Row in ADF ViewObject Programatically

Here I am showing how to insert new row in ADF view object programmatically.

For this create a method in managed bean for your button on that you want to insert row.
and call this AMImpl method that makes use of ViewObjectImpl createRow method to add new row in RowSet

Created a method in AMImpl class and it'll be called in managed bean using binding layer

This method creates a row in ViewObject , and you can set(Insert) this row with some values using this simple snippet of code 

//Get ViewObject Instance
    ViewObjectImpl demoVo = this.getEmployeesDemo1();

// Creates a row in ViewObject
    Row r = demoVo.createRow();  
// You can set attribute values in this new row
    r.setAttribute("EmployeeId", 001); 

//Insert that row in ViewObject
//Commit the changes, If you need

This is how you can create row in ViewObject

Friday 23 November 2012

ADF Basics: Set Default Values in Entity Object for every CreateInsert

Sometimes we have to set some same(default) values for each new row for this we use literal value option in EntityObject XML file or we can set that value in EO(EntityObject) Impl class.
EOImpl Class has a method named

 protected void create(AttributeList attributeList) {

You can set default values there
For this we have to create Entity Impl class of EntityObject , Open EntityObject and select Java tab and click on edit icon

Check Accessors and Create Method checkbox

Now set values using accessors like this -

     * Add attribute defaulting logic in this method.
     * @param attributeList list of attribute names/values to initialize the row
    protected void create(AttributeList attributeList) {
        //Setting default values

or can set in Literal Value of EO xml file

Set default value in Entity Object Literal Value

This is how you can set default values in Entity Object