12 Replies Latest reply: Apr 26, 2013 8:39 AM by PhHein RSS

    how can i append return values

    Tshifhiwa
      hi i have the folowing method i what to return two values
              public   String[]    getChildRoles() {
                  
                     
                  return   this.getUserTypes()  + this.getUsernew();
      
                
              }
        • 1. Re: how can i append return values
          gimbal2
          http://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html
          • 2. Re: how can i append return values
            Tshifhiwa
            the link is about arrays i don't see any append information
            • 3. Re: how can i append return values
              PhHein
              Your method is supposed to return an array, so it's the tutorial you need.
              • 4. Re: how can i append return values
                gimbal2
                adf009 wrote:
                the link is about arrays i don't see any append information
                When you keep refusing to learn Java properly, I can see how this keeps confusing you.
                • 5. Re: how can i append return values
                  Tshifhiwa
                  ok i try this
                          public   String[]   getChildRoles() {
                              
                             int  count = this.getUserTypes().length+ this.getUserTypesS().length;
                             String[] roles = new String[count]  ;
                                  for( count = 0; count < this.getUserTypes().length; count++){
                                      String t = (String)this.getUserTypes()[ count];
                                      roles[count] = t ;
                                      
                                  }
                              for( count = 0; count < this.getUserTypesS().length; count++){
                                  String t = (String)this.getUserTypesS()[ count];
                                  roles[count] = t ;
                                  
                              }
                              
                             
                                 
                              return   roles ;
                  
                             
                          }
                  
                  but am geting this error
                  aused By: java.lang.NullPointerException
                       at view.InternalBean.getChildRoles(InternalBean.java:187)
                       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 javax.el.BeanELResolver.getValue(BeanELResolver.java:261)
                       at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:173)
                       at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:200)
                       at com.sun.el.parser.AstValue.getValue(Unknown Source)
                       at com.sun.el.ValueExpressionImpl.getValue(Unknown Source)
                       at org.apache.myfaces.trinidadinternal.taglib.ForEachTag.doStartTag(ForEachTag.java:117)
                       at jsp_servlet.__intnlusr_jsff._jspx___tag25(__intnlusr_jsff.java:1429)
                       at jsp_servlet.__intnlusr_jsff._jspx___tag24(__intnlusr_jsff.java:1388)
                       at jsp_servlet.__intnlusr_jsff._jspService(__intnlusr_jsff.java:193)
                       at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
                       at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
                       at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
                       at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
                       at weblogic.servlet.internal.ServletStubImpl.onAddToMapException(ServletStubImpl.java:416)
                       at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:326)
                       at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
                       at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
                       at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:119)
                       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:442)
                       at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:103)
                       at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:171)
                       at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
                       at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
                       at weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:524)
                       at weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispatcherImpl.java:444)
                       at weblogic.servlet.jsp.PageContextImpl.include(PageContextImpl.java:163)
                       at weblogic.servlet.jsp.PageContextImpl.include(PageContextImpl.java:184)
                       at oracle.adfinternal.view.faces.taglib.region.IncludeTag.__include(IncludeTag.java:442)
                       at oracle.adfinternal.view.faces.taglib.region.RegionTag$1.call(RegionTag.java:153)
                       at oracle.adfinternal.view.faces.taglib.region.RegionTag$1.call(RegionTag.java:128)
                       at oracle.adf.view.rich.component.fragment.UIXRegion.processRegion(UIXRegion.java:503)
                       at oracle.adfinternal.view.faces.taglib.region.RegionTag.doStartTag(RegionTag.java:127)
                       at jsp_servlet.__index_jspx._jspx___tag3(__index_jspx.java:243)
                       at jsp_servlet.__index_jspx._jspx___tag2(__index_jspx.java:204)
                       at jsp_servlet.__index_jspx._jspx___tag1(__index_jspx.java:154)
                       at jsp_servlet.__index_jspx._jspx___tag0(__index_jspx.java:104)
                       at jsp_servlet.__index_jspx._jspService(__index_jspx.java:65)
                       at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
                       at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
                       at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
                       at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
                       at weblogic.servlet.internal.ServletStubImpl.onAddToMapException(ServletStubImpl.java:416)
                       at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:326)
                       at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:183)
                       at weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:523)
                       at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:253)
                       at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:410)
                       at org.apache.myfaces.trinidad.context.ExternalContextDecorator.dispatch(ExternalContextDecorator.java:44)
                       at org.apache.myfaces.trinidad.context.ExternalContextDecorator.dispatch(ExternalContextDecorator.java:44)
                       at oracle.adfinternal.view.faces.config.rich.RecordRequestAttributesDuringDispatch.dispatch(RecordRequestAttributesDuringDispatch.java:44)
                       at org.apache.myfaces.trinidad.context.ExternalContextDecorator.dispatch(ExternalContextDecorator.java:44)
                       at org.apache.myfaces.trinidad.context.ExternalContextDecorator.dispatch(ExternalContextDecorator.java:44)
                       at org.apache.myfaces.trinidad.context.ExternalContextDecorator.dispatch(ExternalContextDecorator.java:44)
                       at org.apache.myfaces.trinidadinternal.context.FacesContextFactoryImpl$OverrideDispatch.dispatch(FacesContextFactoryImpl.java:267)
                       at com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:469)
                       at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:140)
                       at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:189)
                       at org.apache.myfaces.trinidadinternal.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:193)
                       at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._renderResponse(LifecycleImpl.java:911)
                       at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:367)
                       at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:222)
                       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
                       at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
                       at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
                       at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
                       at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
                       at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
                       at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:205)
                       at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
                       at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:106)
                       at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)
                       at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)
                       at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)
                       at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:271)
                       at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:177)
                       at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
                       at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
                       at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:119)
                       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:442)
                       at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:103)
                       at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:171)
                       at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
                       at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
                       at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:139)
                       at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
                       at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
                       at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
                       at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
                       at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
                       at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
                       at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
                       at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
                       at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
                       at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
                       at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
                       at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
                  Edited by: adf009 on 2013/04/26 1:56 PM
                  • 6. Re: how can i append return values
                    Tolls
                    view.InternalBean.getChildRoles(InternalBean.java:187)

                    You are attempting to do something to something on that line that is null.

                    ANd before you complain that that isn't much of an answer, it's at least on a par with the amount of information you've provided.
                    • 7. Re: how can i append return values
                      939520
                      I'm not sure I follow what you are trying to accomplish, but instead of this:
                      String[] getChildRoles() {

                      You might try something like this:

                      List<ChildRole> childRoles = new Arraylist<ChildRole>();

                      List<ChildRole> getChildRoles{
                      }

                      where ChildRole is a new object that contains both user type and user.

                      Rough example:
                      public class ChildRole{
                        private String user;
                        private String type;
                        
                        public String getUser(){}
                        public String getType(){}
                      
                      }
                      *******************
                      I agree with the previous post. I suggest you read up arrays along with other Java topics.
                      If you haven't already done so, I suggest you go to amazon.com and find a good beginner
                      book on Java that has good reviews and read it cover to cover. Work through several of the book's
                      examples on the command line to learn compiling Java code, etc. Then, download Eclipse IDE and
                      work through more of the books examples with that.
                      • 8. Re: how can i append return values
                        Tshifhiwa
                        its ok i fix the error but now am geting half value in my list am only geting this this.getUserTypesDeeds() values am not geting this.getUserTypesSurvey() in my list
                        • 9. Re: how can i append return values
                          939520
                          I don't think you provided enough information in your latest post for anyone to help. Please explain better and/or provide code.
                          • 10. Re: how can i append return values
                            thomas.behr
                            Both your loops start at index 0. So, the second loop will override the result of the first loop. Since both getUserTypesDeeds() and getUserTypesSurvey() return arrays, use System.arraycopy to fill the roles array.
                            • 11. Re: how can i append return values
                              Tshifhiwa
                              i try this
                              but now am geting this error 
                              Caused By: java.lang.ArrayIndexOutOfBoundsException: 19
                                   at view.InternalBean.getChildRoles(InternalBean.java:227)
                                   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 javax.el.BeanELResolver.getValue(BeanELResolver.java:261)
                                   at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:173)
                                   at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:200)
                                   at com.sun.el.parser.AstValue.getValue(Unknown Source)
                                   at com.sun.el.ValueExpressionImpl.getValue(Unknown Source)
                                   at org.apache.myfaces.trinidadinternal.taglib.ForEachTag.doStartTag(ForEachTag.java:117)
                                   at jsp_servlet.__intnlusr_jsff._jspx___tag25(__intnlusr_jsff.java:1429)
                                   at jsp_servlet.__intnlusr_jsff._jspx___tag24(__intnlusr_jsff.java:1388)
                                   at jsp_servlet.__intnlusr_jsff._jspService(__intnlusr_jsff.java:193)
                              
                              my code is 
                                      public   String[]   getChildRoles() {           
                                         int  count = this.getUserTypesDeeds().length + this.getUserTypesSurvey().length;
                                         int cs=0;
                                         String[] roles = new String[count]  ;   
                                             for( int countt = 0; countt <  this.getUserTypesDeeds().length; countt++){
                                              String  t = (String) this.getUserTypesDeeds()[countt];
                                              roles[countt] = t; 
                                              cs++;
                                      
                                          }
                                          System.out.println("this.getUserTypesSurvey().length " +this.getUserTypesSurvey().length);
                                          System.out.println("this.getUserTypesDeeds().length" + this.getUserTypesDeeds().length);
                                          System.out.println("roles" +roles.length);
                                          for( int counts = 0; counts <  this.getUserTypesSurvey().length; counts++){
                                              
                                              System.out.println("counts" +counts);
                                              String t = (String)this.getUserTypesSurvey()[count];
                                        //      y++;
                                              System.out.println("values " + t);
                                              roles[cs] = t;
                                              System.out.println("TESTY "+ cs);
                                              cs++;
                                              //roles[count] = t;
                                              
                                          }
                                         return roles;
                                          
                                      }
                              
                              this.getUserTypesSurvey().length 10
                              this.getUserTypesDeeds().length9
                              roles19
                              counts0
                              <LifecycleImpl> <_handleException> ADF_FACES-60098:Faces lifecycle receives unhandled exceptions in phase RENDER_RESPONSE 6
                              javax.el.ELException: java.lang.ArrayIndexOutOfBoundsException: 19
                              • 12. Re: how can i append return values
                                PhHein
                                Wrong index variable here:
                                String t = (String)this.getUserTypesSurvey()[count];