Announcement

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

    Potential bug with asAdvancedCriteria

    Hi,

    I've just come across a bug in my application and I don't know if it's a SmartGWT issue or this is what you would expect.

    I've been migrating some of my code to use advanced Criterion over Criteria for my searches.

    I have a TreeGrid which is data bound, when the fetchData is triggered, the Criteria contains the primary key value which allows me to load the current level in the tree. However, since converting the data to advanced criteria, the primary key value gets lost, see the below code snippet

    // My Data Source Snippet....

    DataSourceField idField = new DataSourceTextField(FieldConstants.REFERENCE_COLUMN);
    idField.setHidden(true);
    idField.setPrimaryKey(true);
    fields.add(idField);

    DataSourceField primaryReference = new DataSourceTextField(FieldConstants.PRIMARY_REFERENCE_COLUMN); // "__$$__PRIM_CUST_REF"
    primaryReference.setHidden(true);
    primaryReference.setForeignKey(FieldConstants.REFERENCE_COLUMN);
    fields.add(primaryReference);

    // The fetch Code

    DSRequest request; // Passed in the fetchData request.getCriteria().getValues() Result...

    result = {LinkedHashMap@29901} size = 3
    0 = {LinkedHashMap$Entry@29904} "1" -> "Dale"
    1 = {LinkedHashMap$Entry@29905} "2" -> "E"
    2 = {LinkedHashMap$Entry@29906} "__$$__PRIM_CUST_REF" -> "null"

    Contains a __$$__PRIM_CUST_REF entry

    request.getCriteria().asAdvancedCriteria().getValues() Result...

    result = {LinkedHashMap@29923} size = 3
    0 = {LinkedHashMap$Entry@29926} "_constructor" -> "AdvancedCriteria"
    1 = {LinkedHashMap$Entry@29927} "operator" -> "and"
    key = "operator"
    value = "and"
    2 = {LinkedHashMap$Entry@29928} "criteria" -> " size = 2"
    key = "criteria"
    value = {ArrayList@29934} size = 2
    0 = {LinkedHashMap@29936} size = 3
    0 = {LinkedHashMap$Entry@29940} "fieldName" -> "1"
    1 = {LinkedHashMap$Entry@29941} "operator" -> "iContains"
    2 = {LinkedHashMap$Entry@29942} "value" -> "Dale"
    1 = {LinkedHashMap@29937} size = 3
    0 = {LinkedHashMap$Entry@29951} "fieldName" -> "2"
    1 = {LinkedHashMap$Entry@29952} "operator" -> "iContains"
    2 = {LinkedHashMap$Entry@29953} "value" -> "E"

    Does not contains a __$$__PRIM_CUST_REF entry

    Is this what you would expect or is this a bug?

    Thanks,
    Dale
    GWT Version : 2.7.0
    SmartGWT Version : 5.1p
    SmartGWT Build Date : 01/12/2016 06:19

    #2
    Hi ellis,

    "1" and "2" are not valid fieldNames, see here. I don't know if this changes anything, but you should change this.
    Also, I'd always give a type-information to a DataSourceField. This is required per the docs.

    Best regards
    Blama

    Comment


      #3
      Hi Blama,

      Thansk for reply, won't it know the data type given I've used the Text extension of DataSourceField

      new DataSourceTextField

      Either way, I don't imagine that is the reason why converting Regular criteria to Advanced criteria loses some of the criteria, I wonder if it's because the value is null that it loses it, I think this is a bug still

      Comment


        #4
        If you can eliminate your invalid field names, test with a fully patched build (see smartclient.com/builds) and reproduce this problem in a minimal test case, we can take a look.

        Comment

        Working...
        X