Announcement

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

    How to create an isomorphic AdvancedCriteria from JSON in the server framework.

    Our application stores advanced criteria as user preferences. In the client framework, reinstantiated this saved state is relatively easy.
    Code:
    JavaScriptObject criteria = JSON.decode(criteriaJSON);
    [smartgwt]AdvancedCriteria ac = new AdvancedCriteria(criteria);
    I need to re-create the SQLWhere clause used for a stored criteria outside of a web request (e.g. from a scheduler).

    I know how to do this once I have an AdvancedCriteria object, but how do I Get from the stored JSON to an instantiated com.isomorphic.criteria.AdvancedCriteria object?

    #2
    At the moment, we don't have a helper method that just does this for you. You'd need to use any off-the-shelf JSON parser, then traverse the structure using the com.isomorphic.criteria helper classes to construct AdvancedCriteria.

    Comment


      #3
      Note that SQLDataSource.getSQLClause() is alternative way to store off a query (as a String). But only do this if the storage is relatively short-lived - the AdvancedCriteria JSON format is supported for future versions, but the SQL we generate may change to fix DB flaws and the like.

      Comment


        #4
        Hi, I'm trying to do the exact same thing. Is manual traversal still the best option or has a helper been added in the last year?

        Thanks.

        Comment


          #5
          Hi, same question here. thanks !

          Comment


            #6
            Has anything changed with respect to gbegley's comment, specifically, "...but how do I [g]et from the stored JSON to an instantiated com.isomorphic.criteria.AdvancedCriteria object"?

            Is it still true that "At the moment, we don't have a helper method that just does this for you. You'd need to use any off-the-shelf JSON parser, then traverse the structure using the com.isomorphic.criteria helper classes to construct AdvancedCriteria."?

            Thanks

            SmartClient Version: v9.1p_2014-07-06/Pro Deployment (built 2014-07-06)

            Comment


              #7
              Yes, that's still true, although the posts above also provide other alternatives (like saving the SQL string).

              Comment

              Working...
              X