12 Replies Latest reply: Nov 21, 2012 1:52 AM by 868692 RSS

    checking of row number

    868692
      I am using jdeveloper 11.1.2

      I have have jsff page with table in it

      I can check if this table contain rows using el just like that

      #{bindings.SubmitDCIterator.estimatedRowCount != 0}

      where SubmitDCIterator is the iterator on this table

      but I need to check using el if there are rows with specific condition like the field status = 2

      how can I do that
        • 1. Re: checking of row number
          Alejandro Profet
          Hi belal,

          Maybe this can help: http://adfpractice-fedor.blogspot.com.es/2012/05/working-with-vos-built-in-aggregation.html

          AP
          • 2. Re: checking of row number
            868692
            thank you for your help but this get value for just one row and i want to check if there are specific value in any row
            • 3. Re: checking of row number
              Alejandro Profet
              Actually this applies to get multiple rows in VO using groovy expressions.
              In your case you can do something like this:
              #{bindings.YourVO1.viewObject.sum['Status == 2 ? 1 : 0']}
              It returns the number of rows in YourVO that have Status==2.

              AP
              • 4. Re: checking of row number
                868692
                I want to display link depending on the result of this expression

                If there is one row in the table where status = 5 i want to display the link

                I know how to check if there are row without check status

                so I need something start with bindings.myIterator not bindings.myVO
                • 5. Re: checking of row number
                  Alejandro Profet
                  You need something in your model to estimate whether there is any row with status=5.

                  Try to add this code to your ViewObjectImpl class:
                  private class AgrFuncHelper extends HashMap
                  {
                    private String funcName;
                    public AgrFuncHelper(String funcName)
                    {
                      super();
                      this.funcName = funcName;
                    }
                    public Object get(Object key)
                    {
                      return InvokerHelper.invokeMethod(getDefaultRowSet(), funcName, key);
                    }
                  }
                  public Map getSum()
                  {
                    return new AgrFuncHelper("sum");
                  }
                  public Map getCount()
                  {
                    return new AgrFuncHelper("count");
                  }
                  And the EL expression should look like this:
                  rendered="#{bindings.YourVO1.viewObject.sum['Status==5 ? 1 : 0']}"
                  AP
                  • 6. Re: checking of row number
                    868692
                    after some reading I understand you
                    thank you

                    but when I applied this on my link Render property
                    this error is displayed

                    javax.el.PropertyNotFoundException: //C:/Users/b.othman/AppData/Roaming/JDeveloper/system11.1.2.0.38.60.17/o.j2ee/drs/GMI_V3/ViewControllerWebApp.war/tasks/generalManager/taskList/generalManagerTaskList.jsf @17,125 rendered="#{bindings.SubmitDCIterator.viewObject.sum['Status == 5 ? 1 : 0'] > 0}": The class 'oracle.jbo.server.ViewObjectImpl' does not have the property 'sum'.
                    • 7. Re: checking of row number
                      Alejandro Profet
                      Within what class you put the above code?

                      AP
                      • 8. Re: checking of row number
                        868692
                        I write it on link render property without adding or editing any java class

                        do I need to add class to use 'sum' in my el

                        I need to use this el in many pages on many iterator (15 iterator)

                        is that means I need to create or edit 15 java class
                        • 9. Re: checking of row number
                          Alejandro Profet
                          You can create a base class (extending from ViewObjectImpl) with the magic code and extend to other classes.
                          See this: http://mahmoudoracle.blogspot.com.es/2011/08/adf-business-component-base-classes.html

                          AP

                          Edited by: Alejandro Profet on Nov 20, 2012 12:02 PM
                          • 10. Re: checking of row number
                            868692
                            I will give it a try
                            thanks
                            • 11. Re: checking of row number
                              868692
                              i think it BEGIN to work

                              now I have the following exception

                              Cannot convert 0 of type class oracle.jbo.domain.Number to class java.lang.Long

                              I think the problem that the function sum needs Long while the value 0 in my expression language from type oracle.jbo.domain.Boolean

                              and when I change it like that

                              #{bindings.SubmitDCIterator.viewObject.sum['Status == 5 ? 1 : 0'] < 0}

                              I had this exception :(

                              Cannot convert 0 of type class oracle.jbo.domain.Number to class java.lang.Long


                              how can I fix that?

                              Edited by: belal on Nov 20, 2012 11:02 PM
                              • 12. Re: checking of row number
                                868692
                                I resolve the problem by modifying the java method



                                public Object get(Object key) {



                                /* Object result = new AgrFuncHelper("sum");
                                if (result instanceof oracle.jbo.domain.Number)
                                return Long.parseLong(oracle.jbo.domain.Number)result.toString());*/
                                Object result = InvokerHelper.invokeMethod(getDefaultRowSet(), funcName, key);
                                if(result instanceof oracle.jbo.domain.Number){
                                Long longResult = Long.parseLong(result.toString());
                                return longResult;
                                }

                                return InvokerHelper.invokeMethod(getDefaultRowSet(), funcName, key);
                                }

                                Edited by: belal on Nov 20, 2012 11:52 PM