Announcement

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

    FieldType for a field defined with no type in the ds.xml?

    If I have a field defined in a ds.xml file without the type attribute, what FieldType is it associated to?

    I am just trying to restrict Operators for field types via the call to setTypeOperators and I am not sure what FieldType to use.

    Also, is there a way to set a default set of Operators regardless of the FieldType?

    Thanks.

    #2
    When no field type is defined, "text" is assumed.

    Use setTypeOperators() to set the default operators allowed for each type. There's no way to set the default across all types (because that generally wouldn't make sense).

    Comment


      #3
      OK, thanks.

      I have a field defined as type "any":
      Code:
      <field name="ugroups" type="any">
      and on that DataSource I call:
      Code:
      OperatorId[] ANY_OPERATORS = new OperatorId[] { OperatorId.EQUALS, OperatorId.NOT_EQUAL,
              OperatorId.ICONTAINS, OperatorId.INOT_CONTAINS, OperatorId.IS_NULL, OperatorId.NOT_NULL, OperatorId.AND,
              OperatorId.OR, OperatorId.NOT };
      ds.setTypeOperators(FieldType.ANY, ANY_OPERATORS);
      When I open the filter builder for that field I still see all the operators that I have setup for "text" field type and not the more restricted set defined above. Am I missing something?

      Comment


        #4
        The FilterBuilder can't meaningfully handle fieldType:any - it's not really possible to provide a filtering interface that works with a value of arbitrary type.

        Since there's no intent to handle a typeless field at all, it's not surprising that restricting operators doesn't work - it's just not a supported use case and you'll need to be more specific about type.

        Comment


          #5
          In my case we send an ArrayList<String> as the value and hence the reason the ds.xml has the type="any".

          Should I be doing it differently?

          On the UI it is rendered as a multi-select list component using an option datasource.

          Is text also assumed on the client when the field type in the ds.xml is set as type="any"? Looks like that is the case but I just wanted to clarify since I had assumed the datasource field type on the client would have been FieldType.ANY.

          Once again thanks for your help.

          Comment


            #6
            If a field is text="text" and multiple:true, the expected value for the value is an Array/List of String, so use that.

            Various client-side components will react to type="any" as best they can. In some, it's the equivalent of type="text". Some, like the FilterBuilder, do not try to implement any kind of handling because there is no reasonable way to handle such a field (field type is just too important in this context).

            Comment


              #7
              Excellent, I will change those to do just that. Thanks.

              Comment

              Working...
              X