Please disable your adblock and script blockers to view this page

Search this blog

Friday 13 September 2013

Using af:inputNumberSlider and af:inputRangeSlider for good UI in Oracle ADF

Hello All,
This tutorial is about slider component
Slider is cool and interesting component in ADF to select a single number or to select a range
there is two types of slider available in ADF Faces

1. af:inputNumberSlider (to select single value)
2. af:inputRangeSlider (to select range)

Follow steps to learn how to use slider in ADF
  • Go to Component Palette and search slider and drop it  into page
  • look in property inspector of slider , there are many properties to customise this component, you can change min-max values,orientation etc

  •  See Horizontal and Vertical slider-

  • Now to get its value in bean , bind both slider to managed bean, using binding property



  •     private RichInputNumberSlider numberSliderBind;
        private RichInputRangeSlider rangeSliderBind;
    
    
        public void setNumberSliderBind(RichInputNumberSlider numberSliderBind) {
            this.numberSliderBind = numberSliderBind;
        }
    
        public RichInputNumberSlider getNumberSliderBind() {
            return numberSliderBind;
        }
    
        public void setRangeSliderBind(RichInputRangeSlider rangeSliderBind) {
            this.rangeSliderBind = rangeSliderBind;
        }
    
        public RichInputRangeSlider getRangeSliderBind() {
            return rangeSliderBind;
        }
    

  • now to get value of inputNumberSlider simply use binding.getValue()

  •  Number numberVal = (Number)numberSliderBind.getValue();
    

  • To get Range of inputRangeSlider use this

  •         NumberRange sliderVal = (NumberRange)getRangeSliderBind().getValue();
            Number minVal=sliderVal.getMinimum();
            Number maxVal=sliderVal.getMaximum();
    

  • Now Run your page and see how is it-
You can use slider for custom search, fixed range interval etc

Tuesday 3 September 2013

Avoiding JBO-27101: DeadEntityAccessException, Attempt to access dead entity -Oracle ADF


JBO-27101-DeadEntityAccessException
As Per Oracle docs- JBO-27101: DeadEntityAccessException

Cause: Trying to refer to an invalid/obsolete entity. This could occur if some business logic has held on to an entity reference which was removed and the transaction has been posted or committed. It could also occur if a reference entity has been removed from the cache and any ViewRow is attempting to access it.

Action: Use findByPrimaryKey to find a valid entity of the desired key instead of holding on to a reference to an entity instance.


oracle.jbo.DeadEntityAccessException: JBO-27101: Attempt to access dead entity in DepartmentsEO, key=oracle.jbo.Key[10 ]
 at oracle.jbo.server.EntityImpl.setAttributeValueInternal(EntityImpl.java:3649)
 at oracle.jbo.server.EntityImpl.setAttributeValue(EntityImpl.java:3599)
 at oracle.jbo.server.AttributeDefImpl.set(AttributeDefImpl.java:3193)
 at oracle.jbo.server.EntityImpl.setAttributeInternal(EntityImpl.java:1936)
 at exception.model.entities.DepartmentsEOImpl.setManagerId(DepartmentsEOImpl.java:142)
 at exception.model.entities.DepartmentsEOImpl.doDML(DepartmentsEOImpl.java:229)
 at oracle.jbo.server.EntityImpl.postChanges(EntityImpl.java:6721)
 at oracle.jbo.server.DBTransactionImpl.doPostTransactionListeners(DBTransactionImpl.java:3264)
 at oracle.jbo.server.DBTransactionImpl.postChanges(DBTransactionImpl.java:3067)
 at oracle.jbo.server.DBTransactionImpl.commitInternal(DBTransactionImpl.java:2071)
 at oracle.jbo.server.DBTransactionImpl.commit(DBTransactionImpl.java:2352)
 at oracle.adf.model.bc4j.DCJboDataControl.commitTransaction(DCJboDataControl.java:1590)
 at oracle.adf.model.binding.DCDataControl.callCommitTransaction(DCDataControl.java:1415)
 at oracle.jbo.uicli.binding.JUCtrlActionBinding.doIt(JUCtrlActionBinding.java:1428)
 at oracle.adf.model.binding.DCDataControl.invokeOperation(DCDataControl.java:2169)
 at oracle.jbo.uicli.binding.JUCtrlActionBinding.invoke(JUCtrlActionBinding.java:731)
 at oracle.adf.controller.v2.lifecycle.PageLifecycleImpl.executeEvent(PageLifecycleImpl.java:402)
 at oracle.adfinternal.view.faces.model.binding.FacesCtrlActionBinding._execute(FacesCtrlActionBinding.java:252)
 at oracle.adfinternal.view.faces.model.binding.FacesCtrlActionBinding.execute(FacesCtrlActionBinding.java:185)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at com.sun.el.parser.AstValue.invoke(Unknown Source)
 at com.sun.el.MethodExpressionImpl.invoke(Unknown Source)

This exception mainly occurs when developer/User removes a row from ViewObject and try to access it again to set any value or to commit transaction .
if entity(object of a row in table) is removed and then accessed from cache throws this exception
So Always check code that you have written to remove a row from entity and do check your doDML() method in EntityImpl class as it executes during commit after any DML Operation (Update, Delete).

Steps to reproduce DeadEntityAccessException-
  • here i am using default HR Schema (Departments table)
  • Create business components using Departments table

  • create a page and drag Departments viewObject from data control as a table on page and also drop delete and commit operation on page
  • Now go to EOImpl class of Departments Entity Object and just set any attribute's value in doDML(); method

  •     /**
         * Custom DML update/insert/delete logic here.
         * @param operation the operation type
         * @param e the transaction event
         */
        protected void doDML(int operation, TransactionEvent e) {
            setManagerId(1800);
            super.doDML(operation, e);
        }
    
  • Now just run your application and delete any row then press commit, in this case doDML(); method try to set managerId in deleted row that is not in cache, in this case you will see DeadEntityAccessException




Wednesday 28 August 2013

Cool Component - Using af:richTextEditor as text editor, HTML editor with custom toolbox in Oracle ADF

Hello all,
this post is about af:richTextEditor component in ADF,
This component is used  for text formatting ,colors, it supports links,lables, messages etc and can be used as mail editor, blog editor
  • af:richTextEditor looks like this on page
  • User can use it for text formatting on page as-
  • It supports both Rich text and HTML,you can see by switching over editing modes (Rich text editing mode, Source code editing mode)

  • If you want to use this as simple text editor go to source editing mode and just write plain text



  • One very good thing is that you can use this HTML editor, go to Source Editing Mode and write HTML code, then switch to Rich Text Editing Mode to view result, so it can be used as basic html editor on web page
HTML code-
 Result-
  •  Other than this user can control its toolbox structure and layout, there is a property named ToolboxLayout, some built in value for this property are
       all, font, history ,mode, color, formatAll, formatUncommon, justify, list, indent, link, newline
       look in snaps-