Clarity

  • 1.  GEL WHEN TEST Issue

    Posted Dec 30, 2016 02:52 PM

    Hi All,

    When I test a value, it goes through when it shouldn't succeed.

     

    I am trying to test if a value returned from the database is greater than a parameter value I set.

    My variables show:

    v_emails.rows[0].num = 6

    v_TimeSlice = 20

     

    In what world does 6 > 20?  Is the system somehow converting the value or not returning it?  What's going on where this test succeeds?  How do I get it to TEST the value properly?

     

     

    <core:when test="${v_emails.rows[0].num > v_TimeSlice}">



  • 2.  Re: GEL WHEN TEST Issue

    Posted Dec 30, 2016 02:57 PM

    One more detail:  I set the parameter like this:

      <gel:parameter default="20" var="v_TimeSlice"/>

     

    On the Custom Script Parameters screen, I set it to 20



  • 3.  Re: GEL WHEN TEST Issue

    Posted Dec 30, 2016 04:51 PM

    If the variables in a comparison are different datatypes, then I would expect that you would get unexpected behaviour.



  • 4.  Re: GEL WHEN TEST Issue

    Posted Dec 30, 2016 04:56 PM

    Hi David,

    How would I declare a Parameter as a "number".

     

    I perform a count query from the database and return that value "v_emails.rows[0].num" which returns 6.

     

    How do I get the data types to match?  I don't see a method to set the Parameter to "number"

    Thanks,

    Lowell



  • 5.  Re: GEL WHEN TEST Issue

    Posted Dec 30, 2016 05:06 PM

    On the gel:parameter tag default is a string and v_emails.rows[0].num is an object.

     

    V/r,

    Gene



  • 6.  Re: GEL WHEN TEST Issue

    Posted Dec 30, 2016 05:09 PM

    Hi Gene,

    Does this mean that parameters are useless when it comes to comparing numbers?

     

    And is there a way to convert data types or specify data types so they work?

    Thanks,

    Lowell



  • 7.  Re: GEL WHEN TEST Issue

    Posted Dec 30, 2016 05:14 PM

    Try these to see if you get what you need.

     

    <core:new var="int1" className="java.lang.Integer">
    <core:arg type="java.lang.String" value="${v_TimeSlice}" />
    </core:new>

     

    <core:new var="int2" className="java.lang.Integer">
    <core:arg type="java.lang.String" value="${v_emails.rows[0].num.toString()}" />
    </core:new>

     

    <!-- Might have to call the toString outside JSTL -->

    <core:invoke on="${v_emails.rows[0].num" method="toString" var="v_emails_row"/>
    <core:new var="int3" className="java.lang.Integer">
    <core:arg type="java.lang.String" value="${v_emails_row}" />
    </core:new>

     

    V/r,

    Gene



  • 8.  Re: GEL WHEN TEST Issue

    Posted Dec 30, 2016 05:18 PM

    This one should call the toString by default but I gave up ever expecting jelly to do what java or C# do.

     

    <core:new var="int2" className="java.lang.Integer">
    <core:arg type="java.lang.String" value="${v_emails.rows[0].num}" />
    </core:new>

     

    V/r,

    Gene



  • 9.  Re: GEL WHEN TEST Issue

    Posted Dec 31, 2016 04:39 AM

    IMHO the problem is with the greater than symbol.

    See

    Using >= or <= in query of GEL part 2 

    and Basic guide to getting started with GEL.docx

    eg. in Basic guide to getting started with GEL.docx 



  • 10.  Re: GEL WHEN TEST Issue

    Posted Dec 31, 2016 02:18 PM

    ^ yep, might well be that.



  • 11.  Re: GEL WHEN TEST Issue

    Posted Dec 31, 2016 02:27 PM

    Does not costs or hurt much to test.