Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

  • AdvancedCriteria in DataSource.implicitCriteria: is it possible?

    SmartClient Version: SNAPSHOT_v12.1d_2019-04-04/EVAL Deployment (expires 2019.06.03_07.20.41) Licensed to: Isomorphic Software (#ISC_EVAL_NIGHTLY)

    Hello, I'm trying to use DataSource.implicitCriteria with an AdvancedCriteria.

    I've tried this syntax:

    Code:
        <implicitCriteria operator="and" _constructor="AdvancedCriteria">
                <Criterion fieldName="DATA_CESSAZIONE" operator="isNull"/>
                <criterion operator="and">
                    <criteria>
                        <Criterion fieldName="DATA_DECORRENZA" operator="lessThan" value="$currentDateTime"/>
                        <Criterion fieldName="DATA_CESSAZIONE" operator="greaterThan" value="$currentDateTime"/>
                    </criteria>
                </criterion>
        </implicitCriteria>
    But it produces this fetch criteria:

    Code:
    2019-04-05 18:36:25,564 DEBUG RPCManager Request #1 (DSRequest) payload: {
        criteria:{
            _constructor:"AdvancedCriteria",
            operator:"and",
            Criterion:[
                {
                    fieldName:"DATA_CESSAZIONE",
                    operator:"isNull"
                },
                {
                    operator:"and",
                    criteria:[
                        {
                            fieldName:"DATA_DECORRENZA",
                            operator:"lessThan",
                            value:"$currentDateTime"
                        },
                        {
                            fieldName:"DATA_CESSAZIONE",
                            operator:"greaterThan",
                            value:"$currentDateTime"
                        }
                    ]
                }
            ]
        },
        operationConfig:{
            dataSource:"JOFC_PRESIDENTE_IN_CARICA",
            repo:null,
            operationType:"fetch",
            textMatchStyle:"exact"
        },
    ....
    and I see this message in the log:

    Code:
    2019-04-05 18:36:25,565 WARN  SQLWhereClause [builtinApplication.JOFC_PRESIDENTE_IN_CARICA_fetch] Subcriteria of AdvancedCriteria not an instance of List - using empty ArrayList
    So I've tried this:

    Code:
        <implicitCriteria operator="and" _constructor="AdvancedCriteria">
            <criteria>
                <Criterion fieldName="DATA_CESSAZIONE" operator="isNull"/>
                <criterion operator="and">
                    <criteria>
                        <Criterion fieldName="DATA_DECORRENZA" operator="lessThan" value="$currentDateTime"/>
                        <Criterion fieldName="DATA_CESSAZIONE" operator="greaterThan" value="$currentDateTime"/>
                    </criteria>
                </criterion>
            </criteria>
        </implicitCriteria>
    But on JOFC_PRESIDENTE_IN_CARICA.fetchData()
    I get this js error:
    Code:
    ISC_DataBinding.js?isc_version=v121d_2019-04-04.js:32781 Uncaught TypeError: critArray.removeEmpty is not a function
        at Object.compressNestedCriteria (ISC_DataBinding.js?isc_version=v121d_2019-04-04.js:32781)
        at cons._getCombinedImplicitCriteria (ISC_DataBinding.js?isc_version=v121d_2019-04-04.js:17771)
        at cons.addImplicitCriteria (ISC_DataBinding.js?isc_version=v121d_2019-04-04.js:17779)
        at cons.sendDSRequest (ISC_DataBinding.js?isc_version=v121d_2019-04-04.js:22873)
        at cons.performDSOperation (ISC_DataBinding.js?isc_version=v121d_2019-04-04.js:22701)
        at cons.fetchData (ISC_DataBinding.js?isc_version=v121d_2019-04-04.js:20842)
        at <anonymous>:1:27
    Is it possible to express an AdvancedCriteria in an implicitCriteria?

    Also: is it possible to use a velocity expression in it?

  • Isomorphic
    replied
    Re: #18, DataSource.implicitCriteria is an entirely client-side feature, it is added by client-side components. So it does not affect server-side requests, and will not be added to client-side requests that don't come from a SmartClient UI (eg RestHandler). This clarification will be added to the docs soon.

    Leave a comment:


  • claudiobosticco
    replied
    Originally posted by Isomorphic View Post
    This has now been fixed - you can test out the change in builds dated April 11.

    For clarity, case doesn't matter because advancedCriteria.criteria / criterion.criteria is a multiple="true" field, and we're using the uniform format for such fields.
    I can confirm that it's working for me.

    Leave a comment:


  • Blama
    replied
    Hi Isomorpic

    yes, mixup. It should read:

    OperationBinding.criteria is only applied for client requests, as it is a declarative security feature (see #11).
    Question was if this also applies to DataSource.implicitCriteria or can this be used to e.g. always for all requests filter e.g. deleted='Y' rows.

    Best regards
    Blama

    Leave a comment:


  • Isomorphic
    replied
    Please re-read your last two sentences - there's a thinko in there somewhere as you repeated DataSource.implicitCriteria twice but we think you actually meant to contrast it with something else.

    Leave a comment:


  • Blama
    replied
    Hi Isomorphic,

    Originally posted by Isomorphic View Post
    What do you mean by "the tag is supported"? What tag?
    The DataSource.implicitCriteria tag. It's not in the .ds.xml docs (as of today) and then should be at #implicitCriteria.

    ​​​​​​​
    Originally posted by Isomorphic View Post
    OperationBinding.criteria is for a specific operationBinding and DataSource.implicitCriteria affects all fetches.
    DataSource.implicitCriteria is only applied for client requests, as it is a declarative security feature (see #11).
    Question was if this also applies to DataSource.implicitCriteria or can this be used to e.g. always for all requests filter e.g. deleted='Y' rows.

    Best regards
    Blama

    Leave a comment:


  • Isomorphic
    replied
    What do you mean by "the tag is supported"? What tag?

    OperationBinding.criteria is for a specific operationBinding and DataSource.implicitCriteria affects all fetches.

    Leave a comment:


  • Blama
    replied
    Hi Isomorphic,

    Originally posted by Isomorphic View Post
    For clarity, case doesn't matter because advancedCriteria.criteria / criterion.criteria is a multiple="true" field, and we're using the uniform format for such fields.
    Ah, that makes sense.

    Originally posted by Isomorphic View Post
    This has now been fixed - you can test out the change in builds dated April 11.
    If this means that the tag is supported in .ds.xml DataSource and/or OperationBinding, could you add it to the docs?

    Can you also explain the difference between implicitCriteria and OperationBinding.criteria?

    Best regards
    Blama

    Leave a comment:


  • Isomorphic
    replied
    This has now been fixed - you can test out the change in builds dated April 11.

    For clarity, case doesn't matter because advancedCriteria.criteria / criterion.criteria is a multiple="true" field, and we're using the uniform format for such fields.

    Leave a comment:


  • Isomorphic
    replied
    Apologies, we spoke in error about casing on Criterion - there is indeed a bug with the interpretation of implicitCriteria in DS xml - we'll take a look and update here when it's been fixed.

    If you want to see things work in the meantime, you can specify your implicitCriteria in js code on the DS or on dataBoundComponents.

    Leave a comment:


  • Blama
    replied
    Hi claudiobosticco,

    from what it does I do think that the documented .ds.xml criteria do exactly what client side implicitCriteria do.
    As I stumbled over it: .ds.xml criteria only apply to client initiated requests, not to server-requests (so the same like implicitCriteria defined on a clientside datasource). This is because they are a declarative security feature (this is as answer in some recent thread of mine. I can look it up if necessary.).

    Best regards
    Blama

    Leave a comment:


  • claudiobosticco
    replied
    Originally posted by Blama View Post
    claudiobosticco: Why do you have implicitCriteria in you .ds.xml anyway? I always so only have <criteria... tags and the docs also don't list implicitCriteria.
    Perhaps it's just a wrong tag that does not get removed?
    Hi Blama actually I saw it in the reference https://www.smartclient.com/smartcli...plicitCriteria and I assumed it's available also in the .ds.xml.

    I've asked before about it https://forums.smartclient.com/forum...rid-updatedata and I didn't get a RTM response...for now ;-)

    Leave a comment:


  • Blama
    replied
    Hi Isomorphic, Hi claudiobosticco

    if #8 is true, this seems like an error to me and a case for this thread.
    But I don't see any "Criterion" in my result (assuming that loadDS tag is just another way of a DataSourceLoader-call) using my existing .ds.xml.

    claudiobosticco: Why do you have implicitCriteria in you .ds.xml anyway? I always so only have <criteria... tags and the docs also don't list implicitCriteria.
    Perhaps it's just a wrong tag that does not get removed?

    Best regards
    Blama

    Leave a comment:


  • claudiobosticco
    replied
    Hi Blama, yes I load the dataSource using the loadDS tag, and in the js version of the dataSource I see the implicitCriteria in that form, which doesn't seem correct, so I assume that's why I get a js error when executing dataSource.fetchData.

    Agreed for the Velocity syntax, I just want to understand the correct syntax (or help to understand if it's a bug), and then for my use case I'll use another technique.

    Leave a comment:


  • Blama
    replied
    Hi claudiobosticco,

    Originally posted by claudiobosticco View Post
    ok, but this gives me the same js error:
    ...
    client side, it is translated like that:
    Why *client* side? You are using the tag in a .ds.xml you load with DataSourceLoader, right? IMHO you should only see this in the server logs.
    The "$currentDateTime" is Velocity, so from #2 I assume this is not supposed to work this way.

    Best regards
    Blama

    Leave a comment:

Working...
X