Search in sources :

Example 1 with HtmlProperty

use of org.structr.web.common.HtmlProperty in project structr by structr.

the class DOMElement method getAttributeNode.

public static Attr getAttributeNode(final DOMElement thisElement, final String name) {
    HtmlProperty htmlProperty = DOMElement.findOrCreateAttributeKey(thisElement, name);
    final String value = htmlProperty.getProperty(thisElement.getSecurityContext(), thisElement, true);
    if (value != null) {
        boolean explicitlySpecified = true;
        boolean isId = false;
        if (value.equals(htmlProperty.defaultValue())) {
            explicitlySpecified = false;
        }
        return new DOMAttribute((Page) thisElement.getOwnerDocument(), thisElement, name, value, explicitlySpecified, isId);
    }
    return null;
}
Also used : HtmlProperty(org.structr.web.common.HtmlProperty)

Example 2 with HtmlProperty

use of org.structr.web.common.HtmlProperty in project structr by structr.

the class DOMElement method findOrCreateAttributeKey.

public static HtmlProperty findOrCreateAttributeKey(final DOMElement thisElement, final String name) {
    // try to find native html property defined in DOMElement or one of its subclasses
    final PropertyKey key = StructrApp.getConfiguration().getPropertyKeyForJSONName(thisElement.getEntityType(), name, false);
    if (key != null && key instanceof HtmlProperty) {
        return (HtmlProperty) key;
    } else {
        // create synthetic HtmlProperty
        final HtmlProperty htmlProperty = new HtmlProperty(name);
        htmlProperty.setDeclaringClass(DOMElement.class);
        return htmlProperty;
    }
}
Also used : HtmlProperty(org.structr.web.common.HtmlProperty) PropertyKey(org.structr.core.property.PropertyKey)

Aggregations

HtmlProperty (org.structr.web.common.HtmlProperty)2 PropertyKey (org.structr.core.property.PropertyKey)1