7 Replies Latest reply: Nov 13, 2013 3:51 AM by FredericoSB RSS

    Java ClassCastException -> Treemap to RichTable Selection

    FredericoSB

      Hello everyone,

       

      I have a problem with my selection, whenever i select a "box"/value in my treemap. Whenever i do that, i get the following error:

       

      Caused By: java.lang.ClassCastException: oracle.adf.view.faces.bi.component.treemap.UITreemap cannot be cast to oracle.adf.view.rich.component.rich.data.RichTable

        at utils.GenericTableSelectionHandler.makeCurrent(GenericTableSelectionHandler.java:24)

        at utils.BeanParaPintar2.onFactosTableSelect(BeanParaPintar2.java:180)

       

      Because i pass the selectionEvent to a richtable and i can't do that (I do it in my genericHandler). I'm using adf 12.1.2.0 and in this case, i have 2 adf read-only tables and a treemap and when i select a value in my treemap, i want the read-only tables to update.

       

      Is there any possibility to cast the selectionEvent from a treemap to a Richtable?

       

      Regards,

       

      Frederico.

        • 1. Re: Java ClassCastException -> Treemap to RichTable Selection
          Timo Hahn

          If you use a tree you should use the generic hanlder from http://www.oracle.com/technetwork/developer-tools/adf/learnmore/25-generic-tree-selection-listener-169164.pdf and not the one from the table.

           

          Timo

          • 2. Re: Java ClassCastException -> Treemap to RichTable Selection
            FredericoSB

            Hi TimoHahn,

             

            In this case, i actually need to click on a element in a treemap (not an actual tree) so i think your code doesn't help me a lot :/

            But still, i tried and i get the exception: can't convert treemap to richTree..

             

            Any other idea?

             

            Regards,

            Frederico.

            • 3. Re: Java ClassCastException -> Treemap to RichTable Selection
              FredericoSB

                  public void onFactosTableSelect(SelectionEvent selectionEvent) {

                     

                      UITreemap teste = (UITreemap) selectionEvent.getSource();

                     

                      UITreemap _table = (UITreemap) selectionEvent.getSource();  //the Collection Model is the object that provides the structured data

                   

                     

                      CollectionModel   _tableModel = (CollectionModel) _table.getValue(); //for the table to render

               

                      //the ADF object that implements the CollectionModel is JUCtrlHierBinding. It

                      //is wrapped by the CollectionModel API

                      JUCtrlHierBinding _adfTableBinding = (JUCtrlHierBinding) _tableModel.getWrappedData();

                      //Acess the ADF iterator binding that is used with ADF table binding

                      DCIteratorBinding _tableIteratorBinding = _adfTableBinding.getDCIteratorBinding();

                     

                      //the role of this method is to synchronize the table component selection

                      //with the selection in the ADF model

                      Object _selectedRowData = _table.getSelectedRowKeys();// .getFocusRowKey();// .getCurrentRowData();

                             

                      //cast to JUCtrlHierNodeBinding, which is the ADF object that represents a row

                      JUCtrlHierNodeBinding _nodeBinding = (JUCtrlHierNodeBinding) _selectedRowData;

                     

                      //get the row key from the node binding and set it as the current row in the iterator

                      Key _rwKey = _nodeBinding.getRowKey();

                      _tableIteratorBinding.setCurrentRowWithKey(_rwKey.toStringFormat(true));      

                     

                      // your pre-trigger code ges here ...

                      //GenericTableSelectionHandler.makeCurrent(selectionEvent);

                     

                      //your post-trigger code goes here ...

                      DCIteratorBinding conIter = ADFUtils.findIterator("teste1Iterator");

                      matchEmFactos(conIter.getCurrentRow());

              }

               

              This i what i'm trying to do to solve the problem but i'm getting a null exception from  Object _selectedRowData, because i can't use getSelectedRowData();

               

              Any ideas?

              • 4. Re: Java ClassCastException -> Treemap to RichTable Selection
                Timo Hahn

                If you get a NPE from this line:

                Object _selectedRowData = _table.getSelectedRowKeys();

                this means that _table is null or something happens in the getSelectedRowKeys() method. As we don't see a stack trace we can't tell.

                 

                Timo

                • 5. Re: Java ClassCastException -> Treemap to RichTable Selection
                  FredericoSB

                  <Nov 5, 2013 2:19:21 PM GMT> <Error> <oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter> <BEA-000000> <ADF_FACES-60096:Server Exception during PPR, #1

                  javax.el.ELException: java.lang.ClassCastException: org.apache.myfaces.trinidad.model.RowKeySetTreeImpl cannot be cast to oracle.jbo.uicli.binding.JUCtrlHierNodeBinding

                    at com.sun.el.parser.AstValue.invoke(AstValue.java:258)

                    at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:302)

                    at org.apache.myfaces.trinidad.component.UIXComponentBase.broadcastToMethodExpression(UIXComponentBase.java:1838)

                    at oracle.adf.view.faces.bi.component.treemap.UITreemap.broadcast(UITreemap.java:506)

                    at org.apache.myfaces.trinidad.component.UIXCollection.broadcast(UIXCollection.java:179)

                    at oracle.adf.view.faces.bi.component.treemap.UITreemap.broadcast(UITreemap.java:513)

                    at org.apache.myfaces.trinidad.component.UIXCollection.broadcast(UIXCollection.java:162)

                    at oracle.adf.view.faces.bi.component.treemap.UITreemap.broadcast(UITreemap.java:513)

                    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:759)

                    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:444)

                    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:225)

                    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)

                    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:280)

                    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:254)

                    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:136)

                    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:341)

                    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:25)

                    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)

                    at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:192)

                    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)

                    at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:106)

                    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:478)

                    at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)

                    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:478)

                    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:303)

                    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:208)

                    at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)

                    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)

                    at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:137)

                    at java.security.AccessController.doPrivileged(Native Method)

                    at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:315)

                    at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:460)

                    at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:120)

                    at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:217)

                    at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:81)

                    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)

                    at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:225)

                    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)

                    at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)

                    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)

                    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3367)

                    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3333)

                    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)

                    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)

                    at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)

                    at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2220)

                    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2146)

                    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2124)

                    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1564)

                    at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:254)

                    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:295)

                    at weblogic.work.ExecuteThread.run(ExecuteThread.java:254)

                  Caused By: java.lang.ClassCastException: org.apache.myfaces.trinidad.model.RowKeySetTreeImpl cannot be cast to oracle.jbo.uicli.binding.JUCtrlHierNodeBinding

                    at utils.BeanParaPintar2.onFactosTableSelect(BeanParaPintar2.java:217)

                    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                    at java.lang.reflect.Method.invoke(Method.java:601)

                    at com.sun.el.parser.AstValue.invoke(AstValue.java:254)

                    at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:302)

                    at org.apache.myfaces.trinidad.component.UIXComponentBase.broadcastToMethodExpression(UIXComponentBase.java:1838)

                    at oracle.adf.view.faces.bi.component.treemap.UITreemap.broadcast(UITreemap.java:506)

                    at org.apache.myfaces.trinidad.component.UIXCollection.broadcast(UIXCollection.java:179)

                    at oracle.adf.view.faces.bi.component.treemap.UITreemap.broadcast(UITreemap.java:513)

                    at org.apache.myfaces.trinidad.component.UIXCollection.broadcast(UIXCollection.java:162)

                    at oracle.adf.view.faces.bi.component.treemap.UITreemap.broadcast(UITreemap.java:513)

                    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:759)

                    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:444)

                    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:225)

                    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)

                    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:280)

                    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:254)

                    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:136)

                    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:341)

                    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:25)

                    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)

                    at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:192)

                    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)

                    at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:106)

                    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:478)

                    at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)

                    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:478)

                    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:303)

                    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:208)

                    at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)

                    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)

                    at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:137)

                    at java.security.AccessController.doPrivileged(Native Method)

                    at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:315)

                    at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:460)

                    at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:120)

                    at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:217)

                    at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:81)

                    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)

                    at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:225)

                    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)

                    at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)

                    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)

                    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3367)

                    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3333)

                    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)

                    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)

                    at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)

                    at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2220)

                    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2146)

                    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2124)

                    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1564)

                    at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:254)

                    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:295)

                    at weblogic.work.ExecuteThread.run(ExecuteThread.java:254)

                  >

                   

                  This may happen because i try to get the selectedrowdata as i do it with my generic handler:

                   

                          RichTable _table = (RichTable) selectionEvent.getSource();

                   

                          CollectionModel   _tableModel = (CollectionModel) _table.getValue();

                   

                          JUCtrlHierBinding _adfTableBinding = (JUCtrlHierBinding) _tableModel.getWrappedData();

                          DCIteratorBinding _tableIteratorBinding = _adfTableBinding.getDCIteratorBinding();

                   

                          Object _selectedRowData = _table.getSelectedRowData();

                   

                  But in this particular case, i can't use my generic handler because it is a treemap, so i'm trying to change my code for this purpose but i get a null exception in the object selectedrowdata, probabily because i'm using the wrong method.

                   

                  What do you think?

                  • 6. Re: Java ClassCastException -> Treemap to RichTable Selection
                    FredericoSB

                    I still have the same problem, so i'm going to ask the question from a different way.

                     

                    Is there any chance of getting the value of a selected element in a treemap and cast that element to a richtable ? (or the row in question) ?

                    It has to be a way that enables a person to select a element on a treemap and pass it to a richtable so you could do a query or show some results.

                     

                    Regards,

                     

                    Frederico.

                    • 7. Re: Java ClassCastException -> Treemap to RichTable Selection
                      FredericoSB

                      For anyone trying to select an element (or more) from a treemap and show it in a adf table, the problem is easy to solve, it depends on how you get your value.

                       

                      For example, you can start your code with this:


                      public void onTreeMapSelect(SelectionEvent selectionEvent) {

                              StringBuffer var_DepartmentID = new StringBuffer();

                              UITreemap treemap = (UITreemap) selectionEvent.getSource()

                      ...

                      }

                       

                      With that part of the code (that i found online while researching the treemap proprieties) you can get the element you selected and then you can pass it to a RowKeySet and do an iterator to choose what you can do with your element selected.

                       

                      Good luck to all.

                       

                      Regards,

                      Frederico.