Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

NullPointer exception from getFieldType for custom SimpleType

$
0
0
We use following type, which is based on TEXT type and in addition it is trimming spaces:
Code:

public class TextWithTrimmingType extends SimpleType {
    public TextWithTrimmingType() {
        super(CustomGeneralTypes.textWithTrimming.name(), FieldType.TEXT);
        setValidators(new SpaceTrimmer());
    }
}

public class SpaceTrimmer extends MaskValidator {
    public SpaceTrimmer() {
        setMask("^\\s*(.*?)\\s*$");
        setTransformTo("$1");
    }
}

In onModuleLoad() we call:
Code:

TextWithTrimmingType type = new TextWithTrimmingType();
type.register();

When request is executed we will get a NullPointer exception:
Code:

=== 2015-05-06 18:08:11,744 [80-4] WARN  RequestContext - handleDSRequest() failed:
java.lang.NullPointerException
        at com.isomorphic.datasource.BasicDataSource.getFieldType(BasicDataSource.java:2281)
        at com.isomorphic.datasource.BasicDataSource.validateFieldValue(BasicDataSource.java:1893)
        at com.isomorphic.datasource.BasicDataSource.validateFieldValue(BasicDataSource.java:1877)
        at com.isomorphic.datasource.BasicDataSource.toRecord(BasicDataSource.java:1272)
        at com.isomorphic.datasource.BasicDataSource.toRecords(BasicDataSource.java:1209)
        at com.isomorphic.datasource.BasicDataSource.toRecords(BasicDataSource.java:1170)
        at com.isomorphic.datasource.DataSource.validateDSRequest(DataSource.java:3163)
        at com.isomorphic.datasource.DataSource.validateDSRequest(DataSource.java:3112)
        at com.isomorphic.datasource.DataSourceDMI.execute(DataSourceDMI.java:164)
        at com.isomorphic.datasource.DataSourceDMI.execute(DataSourceDMI.java:64)
        at com.isomorphic.datasource.DSRequest.execute(DSRequest.java:2544)

I have found out that DataSource.getType() first tries to look for typeId in builtInTypes and if it is not found there, then in localDataTypes, which should come from dsConfig parameter "types" ... but when I checked dataSource.getConfig() right before dsRequest.execute(), it is not existing there. Of course we didn't specify it by ourself in ds.xml, but I thought that maybe dsConfig will be somehow enhanced by registered types automatically by framework.

I don't have test case, because example in the showcase is client side only and the EE showcase I am not able to run locally, because of out of memory problem.

The problem is with smartgwt 5.0p and it appeared only after downloading nightly build 5.0-p20150427. I also confirmed that problem is also with current build 5.0-p20150507.

Please, can you have a look? If you need additional information, let me know.
Thanks
Matus

Viewing all articles
Browse latest Browse all 4756

Trending Articles