Follow by Email

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-
  •  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-

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"
                    <f:facet name="nodeStamp">
                        <af:column id="c1" width="500">
                            <af:outputText value="#{node}" id="ot1"/>
                    <f:facet name="pathStamp">
                        <af:outputText value="#{node}" id="ot2"/>

  • 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()) {
                    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()) {
                    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 -

Friday, 23 August 2013

Validation Problem with Cascading mandatory fields in ADF Faces

It is a functional requirement , suppose in application one fields is dependent on another field for its value or any property (required,disable,visible), it means when you select first field and put value in that then second field's value or other property is populated.
or second one is, you have multiple required attributes (cascading) in page and any of that's AutoSubmit  is set to true, in this case when user puts value in first field and goes to second to enter value but before this a large message window appears with required validation and all fields get red

This is very much annoying for user to face this kind of message each time, as i had a scenario where there was 15 required fields in af:form on popup and 10 of that are set to AutoSubmit true .
to avoid this see steps

  • Suppose i have page with create button for Departments table (default HR Schema) on pop up as a form and all fields are reuired
  •  When user clicks on create button and put value in field of DepartmentId, all required fields throw exception

  • To avoid this i have set immediate true for first required field that is DepartmentName, it means when any validation occurs on popup , DepartmentName field will skip all validation on page and will shows only of its own
  •  Now when user put value in DepartmentId field, only DepartmentName field shows exception (required)
 Happy coding......!!

Wednesday, 14 August 2013

Importance of BC4J temp tables(PS_TXN & PS_TXN_SEQ) and Persistent Collections Facility in Oracle ADF

Recently i have seen a new exception in my production environment while 7 users working on deployed application

[2013-08-12T14:06:58.191+05:30] [AdminServer] [WARNING] [ADF_FACES-00009] [] [tid: [ACTIVE].ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: 11] [ecid: a8c0f3836ec62479:-26ea53cb:1407155e369:-8000-00000000000006e7,0] [APP: EBIZADF.ear] Error processing viewId: /ApplicationRoleTF/AppRole URI: /AppRole.jsff actual-URI: /AppRole.jsff.[[
oracle.jbo.PCollException: JBO-28030: Could not insert row into table PS_TXN, collection id 420,356, persistent id 1
 at oracle.jbo.PCollException.throwException(
 at oracle.jbo.pcoll.OraclePersistManager.insert(
 at oracle.jbo.pcoll.PCollNode.passivateElem(
 at oracle.jbo.pcoll.PCollNode.passivate(
 at oracle.jbo.pcoll.PCollNode.passivateBranch(
 at oracle.jbo.pcoll.PCollection.passivate(
 at oracle.jbo.server.DBSerializer.passivateRootAM(
 at oracle.jbo.server.DBSerializer.passivateRootAM(
 at oracle.jbo.server.ApplicationModuleImpl.passivateStateInternal(
 at oracle.jbo.server.ApplicationModuleImpl.passivateState(
 at oracle.jbo.common.ampool.DefaultConnectionStrategy.reconnect(
 at oracle.jbo.server.ApplicationPoolMessageHandler.doPoolReconnect(
 at oracle.jbo.server.ApplicationPoolMessageHandler.doPoolMessage(
 at oracle.jbo.server.ApplicationModuleImpl.doPoolMessage(
 at oracle.jbo.common.ampool.ApplicationPoolImpl.sendPoolMessage(
 at oracle.jbo.common.ampool.ApplicationPoolImpl.prepareApplicationModule(
 at oracle.jbo.common.ampool.ApplicationPoolImpl.doCheckout(
 at oracle.jbo.common.ampool.ApplicationPoolImpl.useApplicationModule(
 at oracle.jbo.common.ampool.SessionCookieImpl.useApplicationModule(
 at oracle.jbo.http.HttpSessionCookieImpl.useApplicationModule(
 at oracle.jbo.common.ampool.SessionCookieImpl.useApplicationModule(
 at oracle.jbo.common.ampool.SessionCookieImpl.useApplicationModule(
 at oracle.adf.model.bc4j.DCJboDataControl.initializeApplicationModule(
 at oracle.adf.model.bc4j.DCJboDataControl.getApplicationModule(
 at oracle.adf.model.binding.DCBindingContainer.findDataControl(
 at oracle.adf.model.binding.DCIteratorBinding.initDataControl(
 at oracle.adf.model.binding.DCIteratorBinding.getDataControl(
 at oracle.adf.model.binding.DCIteratorBinding.getCheckedDataControl(
 at oracle.adf.model.binding.DCIteratorBinding.executeQueryIfNeeded(
 at oracle.adf.model.binding.DCBindingContainer.internalRefreshControl(
 at oracle.adf.model.binding.DCBindingContainer.refresh(
 at oracle.adf.controller.internal.binding.TaskFlowRegionController.doRegionRefresh(
 at oracle.adf.controller.internal.binding.TaskFlowRegionController.refreshRegion(
 at oracle.adf.model.binding.DCBindingContainer.internalRefreshControl(
 at oracle.adf.model.binding.DCBindingContainer.refresh(
 at oracle.adf.controller.v2.lifecycle.PageLifecycleImpl.prepareModel(
 at oracle.adf.controller.faces.lifecycle.FacesPageLifecycle.prepareModel(
 at oracle.adf.controller.v2.lifecycle.Lifecycle$2.execute(
 at oracle.adfinternal.controller.lifecycle.LifecycleImpl.executePhase(
 at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener.access$400(
 at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener$PhaseInvokerImpl.startPageLifecycle(
 at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener$1.after(
 at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener.afterPhase(
 at oracle.adfinternal.controller.faces.lifecycle.ADFLifecyclePhaseListener.afterPhase(
 at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(
 at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(
 at javax.faces.webapp.FacesServlet.service(
 at weblogic.servlet.internal.StubSecurityHelper$
 at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(
 at weblogic.servlet.internal.ServletStubImpl.execute(
 at weblogic.servlet.internal.TailFilter.doFilter(
 at weblogic.servlet.internal.FilterChainImpl.doFilter(
 at oracle.adf.model.servlet.ADFBindingFilter.doFilter(
 at weblogic.servlet.internal.FilterChainImpl.doFilter(
 at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(
 at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(
 at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(
 at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(
 at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(
 at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(
 at weblogic.servlet.internal.FilterChainImpl.doFilter(
 at oracle.adf.library.webapp.LibraryFilter.doFilter(
 at weblogic.servlet.internal.FilterChainImpl.doFilter(
 at weblogic.servlet.internal.FilterChainImpl.doFilter(
 at oracle.dms.servlet.DMSServletFilter.doFilter(
 at weblogic.servlet.internal.FilterChainImpl.doFilter(
 at weblogic.servlet.internal.RequestEventsFilter.doFilter(
 at weblogic.servlet.internal.FilterChainImpl.doFilter(
 at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(
 at weblogic.servlet.internal.WebAppServletContext$
 at weblogic.servlet.internal.WebAppServletContext.securedExecute(
 at weblogic.servlet.internal.WebAppServletContext.execute(
And i was not able understand why this exception occurs, i googled about it and found some very interesting facts about BC4J.

BC4J creates temporary database object (PS_TXN and PS_TXN_SEQ), that are used by ADF to maintain state of user session as per DB, it has facility to store temporary data in BLOB column to avoid out of memory problem.
visit this link to read about these objects- (How to manage PS_TXN and PS_TXN_SEQ)

now i have seen cascading exception after this  oracle.jbo.PcollException, PColl refers persistent collection facility.
when ADF was unable to insert data in PS_TXN table, java.sql.SQLException occurs, connection forcefully closed

Caused by: oracle.jbo.JboException: JBO-29000: Unexpected exception caught: java.sql.SQLException, msg=Connection has already been closed.
 at oracle.jbo.server.DBTransactionImpl.getDatabaseProductName(
 at oracle.jbo.server.DBTransactionImpl.getInternalConnection(
 at oracle.jbo.server.DBTransactionImpl.getPersistManagerConnection(
 at oracle.jbo.pcoll.PCollManager.ensureConnection(
 at oracle.jbo.pcoll.OraclePersistManager.getConnection(
 at oracle.jbo.pcoll.OraclePersistManager.insert(
 at oracle.jbo.pcoll.PCollNode.passivateElem(
 at oracle.jbo.pcoll.PCollNode.passivate(
 at oracle.jbo.pcoll.PCollNode.passivateBranch(
 at oracle.jbo.pcoll.PCollection.passivate(
 at oracle.jbo.server.DBSerializer.passivateRootAM(
 at oracle.jbo.server.DBSerializer.passivateRootAM(
 at oracle.jbo.server.ApplicationModuleImpl.passivateStateInternal(
 at oracle.jbo.server.ApplicationModuleImpl.passivateState(

  • Now i have counted rows in PS_TXN , there was more 3000 rows, have cleared all rows

  • after this again 7 users worked for 3hrs and there was no exception, no bizarre behaviour
  • Now once connection is closed, ADF errors starts coming out as NullPointerException

  • javax.faces.el.EvaluationException: java.lang.NullPointerException
     at org.apache.myfaces.trinidad.component.MethodExpressionMethodBinding.invoke(
     at com.sun.faces.application.ActionListenerImpl.processAction(
     at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(
     at javax.faces.component.UIViewRoot.broadcastEvents(
     at javax.faces.component.UIViewRoot.processApplication(

  • Finally what i come to know that in order to avoid this kind of exceptions , we have to schedule a job to clear data in PS_TXN

What PS_TXN stores-

  • PS_TXN structure- 
  • Suppose you have a search query with more that 10000 records and that is on page as af:table, when user scrolls through table to view records then to avoid out of memory problem bc4j stores extra result set in a temporary storage (PS_TXN) in BLOB column
  • When AM (Application Module) passivates and in AM pooling dofailover is set to true,pending state and changes are stored in this table

  • <AM-Pooling jbo.dofailover="true"/> 

  • In case of Multiple users , session information stored in PS_TXN, each user session must be serialised with database, otherwise database object can't behave as per separate user session
  • to test a scenario , i have deleted all data from PS_TXN in default HR Schema and created a ADF application  that makes uses of HR's tables

  • Run that application , till few operations on application there was no data in PS_TXN table , when i opened application in 3 browser's window and then performed some operations after this there was 2 rows in PS_TXN, it means ADF automatically insert data in PS_TXN for state,session,AM Changes. developer need not to worry about it

At-last summary is - Always keep in mind these db objects if you are facing unexpected behaviour of ADF application in production (multi user) environment, if your application working perfectly on development environment but not in production always check it and schedule a job to clear table PS_TXN