Announcement

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

    FilterBuilder operator "is one of" adds extra spaces between values

    When using an operator that takes a list of values like "is one of" and you enter a list of items, if the value field has focus when you click filter, a space is always added in between the values even if a space already exists.

    Reproducible in the showcase via: http://www.smartclient.com/smartgwt/showcase/#grid_custom_filter_builder

    Attached screen shots shows extra spaces between values just by having focus in the values and clicking "Filter"

    For example, select operator "is one of" and put values "a,b,c" and hit Filter. Then do this repeatedly -click in value to get focus, -click Filter and watch the extra spaces get added over and over.
    Attached Files

    #2
    We've made changes to address this in 5.0 and 4.1 - please retest with a build dated August 15 or later.

    Comment


      #3
      Excellent, Thank You Kindly!

      Comment


        #4
        I am still experiencing a problem with this. If I round-trip the filter: AdvancedCriteria -> JSON encoded String -> AdvancedCriteria, I see the same issue as before. Basically, converting the AdvancedCriteria to the JSON encoded string injects the spaces. Could be I am doing something wrong.

        Included is a simple test code. Just select "is one of" operator and enter a,b,c in the value and click Do button. Then repeatedly click in the value box and click Do button. Spaces keep getting injected. I see them flash to non-space and then back to spaces.

        Using: SmartClient Version: v9.1p_2014-08-28/Pro Deployment (built 2014-08-28)

        Sample Code:
        Code:
        public class Sandbox2 implements EntryPoint {
        
            @Override
            public void onModuleLoad() {
        
                final DataSource dataSource = new DataSource();
                dataSource.setFields(new DataSourceField("First_Name", FieldType.TEXT));
                dataSource.setFields(new DataSourceField("Last_Name", FieldType.TEXT));
        
                final FilterBuilder filterBuilder = new FilterBuilder();
                filterBuilder.setDataSource(dataSource);
                filterBuilder.setRetainValuesAcrossFields(Boolean.FALSE);
                filterBuilder.setTopOperatorAppearance(TopOperatorAppearance.RADIO);
        
                VLayout test = new VLayout();
                test.setWidth(600);
                test.setHeight(400);
                test.addMember(filterBuilder);
                Button button = new Button("Do");
                button.addClickHandler(new ClickHandler() {
                    @Override
                    public void onClick(ClickEvent event) {
                        String jsonCriteria = getJsonEncodedCriteria(filterBuilder);
                        GWT.log(jsonCriteria);
        
                        AdvancedCriteria criteria = AdvancedCriteria.fromJSON(jsonCriteria);
                        filterBuilder.setCriteria(criteria);
        
                    }
                });
                test.addMember(button);
                test.draw();
        
            }
        
            public String getJsonEncodedCriteria(FilterBuilder filterBuilder) {
                AdvancedCriteria ac = filterBuilder.getCriteria();
                JSONEncoder encoder = new JSONEncoder();
                return encoder.encode(ac.getJsObj());
            }
        
        }
        GWT log of the filter showing spaces from the above code doing what was described above:
        Code:
        [INFO] [sandbox2] - {
            "_constructor":"AdvancedCriteria", 
            "operator":"and", 
            "criteria":[
                {
                    "operator":"inSet", 
                    "fieldName":"First_Name", 
                    "value":[
                        "a", 
                        "b", 
                        "c"
                    ]
                }
            ]
        }
        [INFO] [sandbox2] - {
            "_constructor":"AdvancedCriteria", 
            "operator":"and", 
            "criteria":[
                {
                    "operator":"inSet", 
                    "fieldName":"First_Name", 
                    "value":[
                        "a", 
                        " b", 
                        " c"
                    ]
                }
            ]
        }
        [INFO] [sandbox2] - {
            "_constructor":"AdvancedCriteria", 
            "operator":"and", 
            "criteria":[
                {
                    "operator":"inSet", 
                    "fieldName":"First_Name", 
                    "value":[
                        "a", 
                        "  b", 
                        "  c"
                    ]
                }
            ]
        }
        [INFO] [sandbox2] - {
            "_constructor":"AdvancedCriteria", 
            "operator":"and", 
            "criteria":[
                {
                    "operator":"inSet", 
                    "fieldName":"First_Name", 
                    "value":[
                        "a", 
                        "   b", 
                        "   c"
                    ]
                }
            ]
        }
        [INFO] [sandbox2] - {
            "_constructor":"AdvancedCriteria", 
            "operator":"and", 
            "criteria":[
                {
                    "operator":"inSet", 
                    "fieldName":"First_Name", 
                    "value":[
                        "a", 
                        "    b", 
                        "    c"
                    ]
                }
            ]
        }
        [INFO] [sandbox2] - {
            "_constructor":"AdvancedCriteria", 
            "operator":"and", 
            "criteria":[
                {
                    "operator":"inSet", 
                    "fieldName":"First_Name", 
                    "value":[
                        "a", 
                        "     b", 
                        "     c"
                    ]
                }
            ]
        }
        [INFO] [sandbox2] - {
            "_constructor":"AdvancedCriteria", 
            "operator":"and", 
            "criteria":[
                {
                    "operator":"inSet", 
                    "fieldName":"First_Name", 
                    "value":[
                        "a", 
                        "      b", 
                        "      c"
                    ]
                }
            ]
        }
        Last edited by stonebranch1; 29 Aug 2014, 08:41.

        Comment


          #5
          Ah, yes, we see this issue now - we'd missed the part about re-focusing in the textItem - we'll update here when it's fixed

          Comment


            #6
            Very good. Thank you kindly!

            Comment


              #7
              This is fixed - note that the default value of multipleValueSeparator has changed, from comma-space to just comma

              Comment


                #8
                Works great, thanks!

                Comment


                  #9
                  Hi Isomorphic,

                  Originally posted by Isomorphic View Post
                  This is fixed - note that the default value of multipleValueSeparator has changed, from comma-space to just comma
                  I have a problem in this area (thread follows) and I wanted to ask if this is still true, as the docs say otherwise:
                  Default value is ", "
                  Best regards
                  Blama

                  Comment


                    #10
                    Hi Isomorphic,

                    my problem is only happening with v12.0p_2019-03-23 and not with current v12.0p_2019-06-25.
                    Was there a change in how the where clauses are built? Not they are like this: LIKE lower('endangered, %') ESCAPE '\'
                    Before they where LIKE lower('endangered,%') ESCAPE '\' (without the space after the comma).

                    Best regards
                    Blama

                    Comment


                      #11
                      The LIKE clauses are just using the updated separator. Does this seem like it creates a problem?

                      Comment


                        #12
                        Hi Isomorphic,

                        My main question is:
                        What is the separator?
                        To me it seems it is "comma-space" (see the docs link and what is really happening) and not just "comma" like you write in #7.
                        Actually I expect the current behavior as it is doc'd that way and therefore I wanted to ask about the discrepancy between docs and #7.

                        Best regards
                        Blama

                        Comment


                          #13
                          FormItem.multipleValueSeparator was indeed changed from ", " to "," back in 2014 - but that wasn't the proper fix and the change was reverted shortly after, in favour of internal logic which trims the keys as appropriate to deal with the originally reported issue (spaces from the separator-string appearing in keys).

                          Note that FormItem.multipleValueSeparator is a display attribute - the issue regarding criteria was related to the valueSeparator on the inSet operator, which is used in parsing - that attribute remains set to just "," and spaces are trimmed.

                          Comment


                            #14
                            Hi Isomorphic,

                            OK, thanks. That's what I expected. I just wasn't sure about the differences here between forum and docs.

                            With .ds.xml-DataSourceField.multipleValueSeparator, which is a fallback for multipleStorageSeparator, this is also relevant server-side for multiple:true field data serialization/deserialization.
                            This is working for me as expected. I think that I saw unexpected behavior here once, but could not reproduce.

                            Thanks again,
                            Blama

                            Comment

                            Working...
                            X