5 Replies Latest reply on Feb 13, 2007 5:28 PM by Steve Muench-Oracle

    How to compare two jbo.domain.Dates in EL?

    rade.todorovich
      I am trying to disable certain component (JSF) with the EL based on certain date comparison. For example:

      disabled="#{bindings.Whatever.Date1 > bindings.Whatever.Date2}"

      Both dates are oracle.jbo.domain.Date

      and it throws javax.faces.el.ReferenceSyntaxException...

      any idea how to do it properly?
        • 1. Re: How to compare two jbo.domain.Dates in EL?
          rade.todorovich
          I have done little research and found that java.util.Date can be compared. So I have created two dates and stored them into the session:
             java.util.Date date1 = new Date(System.currentTimeMillis());
             myJSFUtils.storeOnSession("date1",date1);
             java.util.Date date2 = new Date(63,0,16);
             myJSFUtils.storeOnSession("date2",date2);
          then I have tried the date comparison to render certain text component in JSF page.
           <af:outputText value="hello world"
                                     rendered="#{sessionScope.date1 gt sessionScope.date2}"/>
          and this works.


          So the question remains: How to compare oracle.jbo.domain.Date??? If I try to do so, ie I have:
          oracle.jbo.domain.Date today = new oracle.jbo.domain.Date(new Date(System.currentTimeMillis()));
          myJSFUtils.storeOnSession("today",today);
          
          .........
          
          <af:outputText value="hello world2"
                                rendered="#{bindings.myVO.EndDate gt sessionScope.today}"/>
          I am getting an error

          500 Internal Server Error
          javax.faces.el.EvaluationException: com.sun.faces.el.impl.ElException: Attempt to apply operator ">" to arguments of type "oracle.jbo.domain.Date" and "oracle.jbo.domain.Date"
          ......
          • 2. Re: How to compare two jbo.domain.Dates in EL?
            rade.todorovich
            Is there a way to 'cast' $^*&#^$ oracle date format into java.util.Date in EL?
            • 3. Re: How to compare two jbo.domain.Dates in EL?
              Steve Muench-Oracle
              Rade,

              By accessing the "value" property of the oracle.jbo.domain.Date object, you can get its value as a java.util.Date.

              So, for example, you could do something like:
              <af:outputText  value="Something"
                                     rendered="#{row.Hiredate.value > bindings.myDate.value}"/>
              • 4. Re: How to compare two jbo.domain.Dates in EL?
                rade.todorovich
                Steve, thank you so much.

                You implied that my date value is gotten from the Iterator hence
                <af:outputText  value="Something"
                                       rendered="#{row.Hiredate.value > bindings.myDate.value}"/>
                and yes that is what I needed but could not really get it to work (no error has been displayed)

                but it worked with:
                <af:outputText  value="Something"
                                       rendered="#{bindings.Hiredate.value > bindings.myDate.value}"/>
                ...again thank you so much.
                • 5. Re: How to compare two jbo.domain.Dates in EL?
                  Steve Muench-Oracle
                  Glad you're going again. Take care.