Skip to content

LabelPropertyView does not handle a null Date #24

@Rocketeer007

Description

@Rocketeer007

I have a radLabel linked to a property which is a Date type, and uses the TimeAgo date format, like this:

<radLabel tag="Symbol.lastRefresh" dateFormat="TimeAgo" component.uiid="RefreshLabel" />

When the property value is null, I'd like to see "N/A", which is how the TimeAgoDateFormatter handles a null (quite nice, in my opinion). However, the logic in LabelPropertyView skips the formatter if the property value is null, and instead formats it as text (meaning I eventually see the text "null").

This is due to the implementation of LabelPropertyView._getText():

private String _getText() {
        Property prop = getPropertySelector().getLeafProperty();
        if (prop == null) {
            return "";
        }
        
        if (prop.getContentType().getRepresentationClass() == Date.class) {
            DateFormatterAttribute formatter = getField().getDateFormatter();
            if (formatter != null) {
                Date val = getPropertySelector().getDate(null);
                if (val != null) {
                    return formatter.getValue().format(val);
                }
            }
        }
                
        
        return getPropertySelector().getText("");
    }

Checking the various DateFormatter implementations, I think they all handle null in their own way, so I'd suggest removing the if (val != null) check.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions