Please disable your adblock and script blockers to view this page

Search this blog

Showing posts with label Jdeveloper. Show all posts
Showing posts with label Jdeveloper. 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) {
           executeOperation("CreateInsert").execute();
        }
    

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

 Cheers :-)

Monday 13 January 2014

Cool Feature- Using 'Placeholder' to set watermark hint on empty input fields in ADF/Jdeveloper 12C

Hello All,
This post talks about a very cool feature , introduced in ADF/Jdeveloper 12C.
Sometimes we need to set some hint on input fields as you can see in facebook sign up form, all fields are self descriptive


So now we can do that in ADF faces easily , in 12C there is a property named 'Placeholder' to define hint for empty fields
You can see in below form (ADF Faces)-


See the xml source of this simple form-




 <af:panelFormLayout id="pfl1">
                    <f:facet name="footer"/>
                    <af:inputText label="Country" id="it1" placeholder="Enter Country Name"
                                  contentStyle="width:200px;color:red;"/>
                    <af:inputDate label="Date" id="id1" placeholder="Select Date"
                                  contentStyle="width:200px;color:red;"/>
                    <af:inputListOfValues label="Country" popupTitle="Search and Result Dialog" id="ilov1"
                                          placeholder="Select Country" contentStyle="width:200px;color:red;"/>
                    <af:inputComboboxListOfValues label="Country" popupTitle="Search and Result Dialog" id="iclov1"
                                                  placeholder="Select Country" contentStyle="width:200px;color:red;"/>
                    <af:inputNumberSpinbox label="Value" id="ins1" placeholder="Enter Or Select"
                                           contentStyle="width:200px;color:red;"/>
                </af:panelFormLayout>

Cheers :-)

Friday 10 January 2014

Oracle ADF Tutorial- How to learn Oracle ADF from scratch ?


Hello All

If you are new to ADF and want to learn this framework then you must be aware of good sources of Oracle ADF tutorials




You must refer a good book to clear your basics as Oracle ADF Real World Developer’s Guide


and start with Oracle ADF Insider videos after that refer Oracle JDeveloper 12c (12.1.3) Tutorials
After this start referring Oracle ADF Blogs for advance development and check all the sample applications provided there, Here you can find some of the best blogs
In case of any problem any issue related to ADF, Ask in OTN forum
Use social media to get new updates about product and blogs




Cheers :-) Happy Learning

Friday 3 January 2014

Identifying Modified/newely added row in af:table, get all modified rows of viewobject in bean

Hello All,
first of all, a very Happy new year to everyone, learn more and more ADF


this tutorial is about a requirement of showing modified rows on page
Suppose if there is lot of data in af:table and user is modifying some rows then it must reflected immediately on page that which rows are modified for more clarity

Andrejus has also posted about it in 2010
http://andrejusb.blogspot.in/2010/04/changed-row-highlighting-in-oracle-adf.html

But this post talks about two requirements-
  1. Want to highlight modified rows only on page
  2. Want to get modified rows in managed bean
First One could be achieved without writing a single line of code only using expression, a row in table or view object has four state-



  • New
  • Modified
  • Un-Modified
  • Initialized


/* this expression returns state of current row in collection such as table or treeTable*/
#{row.row.entities[0].entityState} 

/*here row is reference variable of collection, this expression returns an int value if it is 
 2-Modified
 0-New
 1-Unmodified
-1-Initialized
*/

  • I'm using Departments table of HR Schema to implement this sample app
  • after business components configuration ,Drop departments VO from data control on page as af:table
  • Now to check row status , i have written following expression in inline style of af:column of af:table, so that it can check state of all rows of table 

  • #{row.row.entities[0].entityState==2 ? 'background-color:orange' : row.row.entities[0].entityState==0 ? 'background-color:darkgreen' : ''} 
    

  • Now Run your page and change any value of table
       After Updating Values in Row- see modified rows are highlighted
  •  Now you are done with first requirement , if we talk about second one, in case you want to get all modified rows in managed bean to perform some operation
  • To achieve this i have used a transient attribute in Departments view Object to store state of each row
  • Now in RowImpl of departments viewobject i have to write some code to get current state of Row, see the getter method of transient attribute in RowImpl

  •     /**
         * Gets the attribute value for the calculated attribute CheckRowStatus.
         * @return the CheckRowStatus
         */
        public Integer getCheckRowStatus() {
            byte entityState = this.getEntity(0).getEntityState();
            return new Integer(entityState);
    
            // return (Integer) getAttributeInternal(CHECKROWSTATUS);
        }
    

  • Now i have placed a button on page to get all modified rows and show a message on page through managed bean
  • See the method written in ApplicationModuleImpl class and then exposed to client to be used in managed bean action event

  •     /**Method to get all modified rows and store corresponding Department Name in an ArrayList
         * @return
         */
        public ArrayList<String> getModifiedRows() {
            ArrayList<String> deptNm = new ArrayList<String>();
            ViewObject deptVo = this.getDepartmentsView1();
            RowSetIterator deptIter = deptVo.createRowSetIterator(null);
            while (deptIter.hasNext()) {
                Row nextRow = deptIter.next();
                if (nextRow.getAttribute("CheckRowStatus") != null) {
                    Integer rowStatus = (Integer)nextRow.getAttribute("CheckRowStatus");
                    if (rowStatus == 2) {
                        deptNm.add(nextRow.getAttribute("DepartmentName").toString());
                    }
                }
            }
            return deptNm;
    
        }
    

  • Now call this method in managed bean through Binding Layer

  •     /**Method to get BindingContainer of current page
         * @return
         */
        public BindingContainer getBindings() {
            return BindingContext.getCurrent().getCurrentBindingsEntry();
        }
    
        /**Method to call AM method and to show modified rows on page in FacesMessage
         * @param actionEvent
         */
        public void getModifiedRows(ActionEvent actionEvent) {
            OperationBinding ob = getBindings().getOperationBinding("getModifiedRows");
            ob.execute();
            if (ob.getResult() != null) {
                ArrayList<String> deptName = (ArrayList<String>)ob.getResult();
                StringBuilder saveMsg =
                    new StringBuilder("<html><body><b><p style='color:red'>Modified Rows in Departments table are-</p></b>");
    
                saveMsg.append("<ul>");
                for (String name : deptName) {
                    System.out.println(name);
                    saveMsg.append("<li> <b>" + name + "</b></li>");
                }
    
                saveMsg.append("</ul><br>");
                saveMsg.append("</body></html>");
                FacesMessage msg = new FacesMessage(saveMsg.toString());
                FacesContext.getCurrentInstance().addMessage(null, msg);
            }
        }
    

  • Now again run this page and change some departments then click on get modified rows, it will show currently modified rows

Cheers- Download Sample App

Wednesday 18 December 2013

Changing default text of af:dialog buttons (ok,cancel) in ADF

Hello All,
you all have used pop up component with af:dialog in ADF,
default dialog component look like this inside popup



in ADF there is option to change dialog type , select dialog component and go to property inspector-


But sometimes we need to change default dialog button's text as per our requirement, to do this follow steps mentioned below

  • Drag a popup having dialog as its child component on page
  • select af:dialog in structure window and go to property inspector

  • In property inspector navigate Appearance--->Text 



  • Now set values for Affirmative and cancel text 
     
  • Now run your application and see-
     


  • But it's outcome doesn't get changed as it is static, you can see this in managed bean code, i have created dialog Listener and a cancelListener in managed bean 

  • import javax.faces.application.FacesMessage;
    import javax.faces.context.FacesContext;
    
    import oracle.adf.view.rich.event.DialogEvent;
    import oracle.adf.view.rich.event.PopupCanceledEvent;
    
    
    public class DialogListenerBean {
        public DialogListenerBean() {
        }
    
        public void dialogListener(DialogEvent dialogEvent) {
            FacesMessage msg = new FacesMessage("You have clicked- " + dialogEvent.getOutcome().name());
            FacesContext.getCurrentInstance().addMessage(null, msg);
        }
    
        public void cancelListener(PopupCanceledEvent popupCanceledEvent) {
            FacesMessage msg = new FacesMessage("You have clicked- cancel");
            FacesContext.getCurrentInstance().addMessage(null, msg);
        }
    }
    

  • When you click on ok and cancel (with changed text), it will return same outcome that was before changing button's text

Cheers- Merry Christmas :-)

Monday 23 September 2013

Dynamically enable or disable items of ADF bound List (af:selectOneChoice) -Oracle ADF

Hello All,
This tutorial is about a requirement of conditionally enabling/disabling items (values) of adf bound List (af:selectOneChoice) component
here i am taking reference of default HR Schema (Departments and Location table )

See the steps-
  • Create a Fusion Web Application and business components using both tables
  •  Now create List of Values (Lov) on locationId of departments VO from Location VO
  • Set List Attribute to LocationId and for UI city will be shown
  • Now Drag Departments VO from Data Control on page as a form
  •  Select LocationId list field and delete f:selectItems from it, now drag af:selectItem as child of af:selectOneChoice and surround it with af:forEach 



  • Add tree binding of Location ViewObject to page bindings in order to populate list items using forEach
  •  Now select af:forEach and set its property and variable name, as we have to iterate through Location VO for list items
  •  Again select af:selectItem and set its value and label property using forEach variable's  
  • Now run your application, and see that list box is ready with values
  • Now we have to disable its values as a condition basis, i have written an Expression on af:selectItem's disabled property


  • I have written condition for DepartmentId 100 and 110, see in source of page

  • <af:selectOneChoice value="#{bindings.LocationId.inputValue}" label="#{bindings.LocationId.label}"
                                            required="#{bindings.LocationId.hints.mandatory}"
                                            shortDesc="#{bindings.LocationId.hints.tooltip}" id="soc1"
                                            contentStyle="width:150px;color:red;">
                            <af:forEach items="#{bindings.Locations1.rangeSet}" var="list">
                                <af:selectItem label="#{list.City}" id="si1" value="#{list.LocationId}"
                                               disabled="#{ (bindings.DepartmentId.inputValue==100 and (list.LocationId==1000 || list.LocationId==1300)) || (bindings.DepartmentId.inputValue==110 and (list.LocationId==1500 || list.LocationId==1600 || list.LocationId==1700 || list.LocationId==1800 || list.LocationId==1900))}"/>
                            </af:forEach>
                        </af:selectOneChoice>
    

  • Now value given in Expression for Location Id will be disabled for given Department
  • Run your page and select DepartmentId 100 and 110 to see disabled list items

 Download Sample App Cheers :-)

Tuesday 17 September 2013

Bug in ADF 11g R2- Transient and Bind Valiable of Timestamp type

This is a bug in ADF 11g R2, and sometimes so much annoying for developer.

Bug Is-

  • Suppose you have created business components for Employees table of HR Schema, there is HireDate in Employees table , see it in EntityObject-

  • Now go to source and see, it is of type oracle.jbo.domain.Timestamp (default java representation of Timestamp database data type )

  • Now go to Employees ViewObject and create a transient variable for DOB(Date Of Birth)  and select it as Timestamp
  •  Now after this if developer tries to get or set value of this transient variable, it shows a exception (java.sql.Timestamp can not be cast to oracle.jbo.domain.Timestamp)



  •  To solve this error go to Employees ViewObject and select transient attribute and go to source, se it is of type java.sql.Timestamp

  • Change it to oracle.jbo.domain.Timestamp  and then run it
  • So this is a bug when developer creates new Transient or Query bind variables of Timestamp type, ADF automatically assign it java.sql.Timestamp
Always check it when using Jdveloper 11gR2

Cheers... happy debugging

Monday 26 August 2013

Tree Table Component with declarative presentation in ADF, Access childs without custom selection listener

Hello all,
this is my second post on af:treeTable, first post was about creating and overriding tree table selection listener to get node value in managed bean, see
Tree Table Component in Oracle ADF(Hierarchical Representation)

In this post i am going to explain how to
  • use multiple detail column in treeTable
  • design better UI
  • manage child rows
  • use link,image,checkbox in treeTable conditionally
so i assume that you all know about creating treeTable, i am using default HR Schema (Employees ,Departments table) to master detail relation in tree and i have to show detail of Employee under Department node
  • I have created a treeTable using following details of Employees VO
  • Now on running my page it is looking like this, very odd and complex view
        xml source-

  <af:treeTable value="#{bindings.Departments1.treeModel}" var="node"
                              selectionListener="#{bindings.Departments1.treeModel.makeCurrent}" rowSelection="single"
                              id="tt1">
                    <f:facet name="nodeStamp">
                        <af:column id="c1" width="500">
                            <af:outputText value="#{node}" id="ot1"/>
                        </af:column>
                    </f:facet>
                    <f:facet name="pathStamp">
                        <af:outputText value="#{node}" id="ot2"/>
                    </f:facet>
                </af:treeTable>

  • It shows that all details of employees are clubbed in one column that is nodestamp, now to show details in different columns i have added 5 columns in treeTable, and seperate detail in each column as Email, FirstName,LastName etc
    To add column right click on treeTable and insert-
 In column drop an input text and set its value taking node reference




  •  Now run page and see, there is now 5 column with different details but still that clubbed value is shown.
  • Now to remove that clubbed detail, go to nodestamp facet of treeTable and see value of output text inside column, it is set to #{node} ,due to this all values available in node are clubbed and displayed in page, now we have to set its value to any of Master table's (Departments) attribute



  •  Now run page , only department name is displayed on header, and corresponding value for detail is blank
  •  We are done with this part, now try to make its UI somewhat better using some styles, so i have used different background color for header and detail part of treeTable conditionally
  • To do this i have set inline style property conditionally , because i have to change color of same column according to master and detail data, see condition

  • #{node.DepartmentName!=null ? 'background-color:darkgreen' :  'background-color:rgb(239,255,213);'  }
    

  • Now see how to get selected child row without over-riding treeTable's selection listener, to do this i have added a image link in treeTable and created a action listener on that to show current selected detail row
  • Bind tree table to managed bean and create two methods to get selected RowIterator and node Key

  •     /**Tree Table Binding in managed bean*/
        private RichTreeTable treeTabBind;
    
        public void setTreeTabBind(RichTreeTable treeTabBind) {
            this.treeTabBind = treeTabBind;
        }
    
        public RichTreeTable getTreeTabBind() {
            return treeTabBind;
        }
    
        /**Method to get Iterator*/
        public RowIterator getSelectedNodeIterator() {
            if (getTreeTabBind() != null && getTreeTabBind().getSelectedRowKeys() != null) {
                for (Object rKey : getTreeTabBind().getSelectedRowKeys()) {
                    getTreeTabBind().setRowKey(rKey);
                    return ((JUCtrlHierNodeBinding)getTreeTabBind().getRowData()).getRowIterator();
                }
            }
            return null;
        }
    
        /**Method to get Node Key*/
        public Key getSelectedNodeKey() {
            if (getTreeTabBind() != null && getTreeTabBind().getSelectedRowKeys() != null) {
                for (Object rKey : getTreeTabBind().getSelectedRowKeys()) {
                    getTreeTabBind().setRowKey(rKey);
                    return ((JUCtrlHierNodeBinding)getTreeTabBind().getRowData()).getRowKey();
                }
            }
            return null;
        }
    

  • Now to get currently selected node and row pass Iterator and Node key in this method- see

  •     public void showCurRowDetail(RowIterator ri, Key selectedNodeKey) {
            Row[] rows = ri.findByKey(selectedNodeKey, 1);
    
            FacesMessage msg = new FacesMessage(rows[0].getAttribute("FirstName") + "'s data available in this row");
            FacesContext.getCurrentInstance().addMessage(null, msg);
        }
    

  • Now Run application and click on link to see selected row -