Announcement

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

    Custom datatype and server-side error logs

    Hello,

    i have, for a long time, had a custom datasource for "position" fields. The reason for this was originally that localization made floats look different and in some instances not work with google maps and/or sending back to server.
    I therefor had a need to have certain types of float fields always be serialized up and down the same way.

    I set it up according to this thread: https://forums.smartclient.com/forum...ng-and-editing

    I then use the type in my datasource xml definition like this:
    Code:
    <field name="lon" type="position" length="256" required="true" hidden="false">
        <validators>
           <validator type="isFloat"/>
        </validators>
    </field>
    This has worked for several years, and still do. However, i just noticed something in the logs that i haven't looked at in a long while. The server logs is overrun with smartclient rows of the type:
    Code:
    2018-11-12 10:44:56.307 DEBUG com.isomorphic.store.DataStructCache - getInstanceFile (failure): 'position' instance of datasources: 0ms
    2018-11-12 10:44:56.307 DEBUG c.i.d.PoolableDataSourceFactory - Tried to create DataSource  of type 'position' but null was returned
    It seems as though it is because it does not recognize the position custom type?

    So, my questions:
    1. Is this still the best way to get global formatting of certain types of fields, or would you recommend something else?
    2. What can i do to get rid of the server-side logs?


    for reference, here is how i register the custom datatype client-side:

    Code:
        private static native void createNumericSimpleType(String name) /*-{
            $wnd.isc.ClassFactory.defineClass(name, "TextItem");
    
            $wnd.isc.ClassFactory.getClass(name).addProperties({
                mapDisplayToValue : function(value) {
                    retVal = @xxx.CustomDataSourceTypesFactory::parseNumericValue(Ljava/lang/String;Ljava/lang/String;)(name, value);
                    if (isNaN(retVal))
                        return value;
                    return retVal;
                },
                mapValueToDisplay : function(value) {
                    if (value == null)
                        return "";
                    else if (isNaN(value))
                        return value;
                    else {
                        return @xxx.CustomDataSourceTypesFactory::formatNumericValue(Ljava/lang/String;D)(name, value);
                    }
                }
            });
    
            $wnd.isc.SimpleType.create({name:name,
                inheritsFrom:"float",
                editorType:name,
                normalDisplayFormatter:function(internalValue) {
                    return this.shortDisplayFormatter(internalValue);
                },
                shortDisplayFormatter:function(value) {
                    if (value == null)
                        return "";
                    else if (isNaN(value))
                        return value;
                    else {
                        return @xxx.CustomDataSourceTypesFactory::formatNumericValue(Ljava/lang/String;D)(name, value);
                    }
                }
            });
        }-*/;
    Last edited by mathias; 11 Nov 2018, 21:08.

    #2
    This is fine. They are DEBUG-level logs for a reason - they are just checking whether you have a DataSource for that type, but having one is not required, and it's normal for such a type lookup to happen and report failure to find a DataSource.

    Comment


      #3
      OK, good to know. It still seems like a lot of unneccessary processing, apparently every time i send or receive something in any datasource that has such fields.

      Comment


        #4
        There are lookups like this going on for types constantly, and it's all cached and efficient. If you're worried about performance, in your production environment, don't have DEBUG logging on for this category.

        Comment

        Working...
        X