Announcement

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

    VelocityExpression into an implicitCriteria, is that possible?

    SmartClient version: v11.0p_2016-03-31/EVAL Development Only

    Hi isomorphic , I'm trying to use implicitCriteria with VelocityExpression , but I get an error .

    The expression is not resolved, so a string is passed instead of a real value.

    xml code:
    Code:
     <implicitCriteria>
            <Criterion fieldName="ID_APP_FK" operator="equals">
                <value>$sessionAttributes.user.appID</value>
            </Criterion>
        </implicitCriteria>

    Error:

    Code:
    === 2016-04-06 13:18:42,974 [c-10] DEBUG RPCManager - Request #1 (DSRequest) payload: {
    criteria:{
            fieldName:"ID_APP_FK",
            operator:"equals",
            value:"$sessionAttributes.user.appID"
        },
        operationConfig:{
            dataSource:"ACTORS",
            repo:null,
            operationType:"fetch",
            textMatchStyle:"exact"
        },
        appID:"builtinApplication",
        operation:"ACTORS_fetch",
        oldValues:{
            fieldName:"ID_APP_FK",
            operator:"equals",
            value:"$sessionAttributes.user.appID"
        }
    }
    === 2016-04-06 13:18:42,974 [c-10] INFO  IDACall - Performing 1 operation(s)
    === 2016-04-06 13:18:42,974 [c-10] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null
    === 2016-04-06 13:18:42,974 [c-10] DEBUG DeclarativeSecurity - DataSource ACTORS is not in the pre-checked list, processing...
    === 2016-04-06 13:18:42,974 [c-10] DEBUG DeclarativeSecurity - Processing security checks for DataSource ACTORS_TYPES, field ID_REC
    === 2016-04-06 13:18:42,974 [c-10] DEBUG DeclarativeSecurity - DataSource ACTORS_TYPES is not in the pre-checked list, processing...
    === 2016-04-06 13:18:42,974 [c-10] DEBUG DeclarativeSecurity - Processing security checks for DataSource ACTORS_TYPES, field IS_SUBJECT
    === 2016-04-06 13:18:42,974 [c-10] DEBUG DeclarativeSecurity - DataSource ACTORS_TYPES is not in the pre-checked list, processing...
    === 2016-04-06 13:18:42,974 [c-10] DEBUG DeclarativeSecurity - Processing security checks for DataSource ACTORS_TYPES, field ID_REC
    === 2016-04-06 13:18:42,974 [c-10] DEBUG DeclarativeSecurity - Processing security checks for DataSource ACTORS_TYPES, field IS_OBJECT
    === 2016-04-06 13:18:42,974 [c-10] DEBUG DeclarativeSecurity - Processing security checks for DataSource ACTORS_TYPES, field ID_REC
    === 2016-04-06 13:18:42,974 [c-10] DEBUG DeclarativeSecurity - Processing security checks for DataSource ACTORS_TYPES, field TYPE
    === 2016-04-06 13:18:42,974 [c-10] DEBUG AppBase - [builtinApplication.ACTORS_fetch] No userTypes defined, allowing anyone access to all operations for this application
    === 2016-04-06 13:18:42,974 [c-10] DEBUG AppBase - [builtinApplication.ACTORS_fetch] No public zero-argument method named '_ACTORS_fetch' found, performing generic datasource operation
    === 2016-04-06 13:18:42,975 [c-10] INFO  SQLDataSource - [builtinApplication.ACTORS_fetch] Performing fetch operation with
        criteria: {fieldName:"ID_APP_FK",operator:"equals",value:"$sessionAttributes.user.appID"}    values: {fieldName:"ID_APP_FK",operator:"equals",value:"$sessionAttributes.user.appID"}
    === 2016-04-06 13:18:42,975 [c-10] WARN  SQLWhereClause - [builtinApplication.ACTORS_fetch] String '$sessionAttributes.user.appID' was passed as filter criteria for a numeric field. We could not parse it.
    I thought that the user variable wasn't in session, so i tried to use $currentDate on a date field, but i got the same error.

    i'm doing something wrong, or i cannot do it?

    #2
    Hi simokris,

    is this xml you are showing from a .ds.xml- or from a ComponentXML-file?

    in .ds.xml, this is working for me:
    Code:
            <operationBinding ...>
                <criteria fieldName="ID" operator="equals" value="$session.authenticatedUserID" />
            </operationBinding>
    Perhaps this helps.

    Best regards
    Blama

    Comment


      #3
      Originally posted by Blama View Post
      Hi simokris,

      is this xml you are showing from a .ds.xml- or from a ComponentXML-file?

      in .ds.xml, this is working for me:
      Code:
       &lt;operationBinding ...&gt;
      &lt;criteria fieldName="ID" operator="equals" value="$session.authenticatedUserID" /&gt;
      &lt;/operationBinding&gt;
      Perhaps this helps.

      Best regards
      Blama
      Hi blama, thanks for the answer.

      The snippet of the xml is from a .ds.xml file.

      I written, the code above, thinking about how the operationdBinding works, because i've already used VelocityExpression with operationbinding, so i tried to replicate the same structure. But it doesn't work with implicitCriteria.

      I tried several times, using <criteria> or <values> or <field> tags
      and the criteria generated are always dropped.
      Except with the<Criterion> tag, where i get the error above specified. So I thought it could not do.

      Comment


        #4
        Hi simokris,

        did you try my version? Perhaps 1st with hardcoded values, then with velocity variables?
        It is working for me.
        It does also work with AdvancedCriteria, see here.

        Best regards
        Blama

        Comment


          #5
          The simple case is also shown in the QuickStartGuide, chapter "Server-Assigned Criteria/Values".

          Comment


            #6
            Yes, i tried the your version in this way.

            Code:
            <implicitCriteria fieldName="ID_APP_FK" operator="equals" value="1">
             </implicitCriteria>
            And it works, but using hardcoded value. with the VelocityExpression i get the same error.

            Same results with:

            Code:
            <implicitCriteria>
                    <Criterion fieldName="ID_APP_FK" operator="equals">
                        <value>1</value>
                    </Criterion>
                </implicitCriteria>
            It works with hardcoded value, not with VelocityExpression.

            Comment


              #7
              Why do you use implicitCriteria instead of criteria? Where did you read about it and what is your expectation?

              Best regards
              Blama

              Comment


                #8
                Well..

                Click image for larger version

Name:	DataSource_implicitCriteria.png
Views:	77
Size:	43.0 KB
ID:	236620


                This screenshot is from isc version : " SNAPSHOT_v11.1d_2016-04-06 / EVAL Development Only" LINK

                So , my " ID_APP_FK " is a foreign key that links togheter a group of person and I Need That All fetches contain the same ID_APP_FK value of the logged user

                I Know That the implicitCriteria is the same thing that do :

                Code:
                <operationBindings>
                        <operationBinding operationType="fetch">
                            <whereClause>$defaultWhereClause AND ACTORS.ID_APP_FK = $sessionAttributes.user.appID</whereClause>
                        </operationBinding>
                    </operationBindings>
                But implicitCrteria is a new feature, recently introduced, that would be perfect for my case.
                Last edited by simokris; 7 Apr 2016, 00:44.

                Comment


                  #9
                  Hi simokris,

                  ah, it gets clearer. This is the SmartClient forum and I'm using SmartGWT.
                  I'd expect that Criterion will require and enclosing AdvancedCriteria. See the linked thread in post#4.

                  Isomorphic:
                  The implicitCriteria-feature seems to be added in 11.0/6.0 and is not available in 10.1/5.1, correct?
                  If so, this would be great as it is this one, isn't it? Will it also work in .ds.xml? I did not update to 6.0, yet.

                  Thank you & Best regards
                  Blama

                  Comment


                    #10
                    Hi Isomorphic,

                    could you answer my question from #9?

                    Thank you & Best regards
                    Blama

                    Comment


                      #11
                      Yes, implicitCriteria is a new 6.0 / 11.0 feature.

                      Comment


                        #12
                        Hi Isomorphic,

                        what about the other two. It's not in the SmartGWT .ds.xml docs, yet. This is not correct, is it?
                        And can it be described as "like .ds.xml criteria, but applied always, not only for client requests".

                        Best regards
                        Blama

                        Comment


                          #13
                          It's a client-side only feature for now - no use for enforcing security rules.

                          Comment


                            #14
                            Hi Isomorphic,

                            OK, thank you.

                            Best regards
                            Blama

                            Comment

                            Working...
                            X