Interface AttributeWebWidget
- All Superinterfaces:
AttributeWidget
A widget-producer, creating a widget that can be used to present values in a
web environment.
- Author:
- Per-Erik
-
Nested Class Summary
Nested classes/interfaces inherited from interface se.conciliate.extensions.attribute.AttributeWidget
AttributeWidget.WidgetType
-
Method Summary
Modifier and TypeMethodDescriptiongetRenderer
(AttributeWidget.WidgetType widgetType, AttributeDataType type, Map<String, Refinement> refinements) Returns the body of a JavaScript function with the following function header:
render(value, attributeType, dataObject, language, parent, lookup)
With type information, this function would look like:
void render(String value, String attributeType, String dataObject, String language, JQueryObject parent, Function lookup)
The "contract" of the function is to add child elements to the parentElement (a jquery xml element).Methods inherited from interface se.conciliate.extensions.attribute.AttributeWidget
getID, getName, getSupportedWidgetTypes, isSupported
-
Method Details
-
getRenderer
String getRenderer(AttributeWidget.WidgetType widgetType, AttributeDataType type, Map<String, Refinement> refinements) Returns the body of a JavaScript function with the following function header:
render(value, attributeType, dataObject, language, parent, lookup)
With type information, this function would look like:
void render(String value, String attributeType, String dataObject, String language, JQueryObject parent, Function lookup)
The "contract" of the function is to add child elements to the parentElement (a jquery xml element). The function may add any kind of content, but it is preferred to only add non-positional elements (that is, not divs, iframes and the likes). If the content is reasonably complex, a good way to keep this preferred behavior and still render a complex structure is to add a <a> to the parent and have the link open a top-most div when clicked.
The arguments further explained:
Example value
The raw value of the attribute attributeType
A uuid for the attribute's type dataObject
A uuid for the data object that the attribute is connected to language
The preferred language to render in parent
The jquery object (dom element) to add content to lookup
A lookup function that takes a "type" and a uuid, and finds the object that the uuid refers to. The type argument is either "dataObject", "attributeType" or "language". The return value is a deferred (Promises/A+) object that will resolve the lookup or fail if a type with the supplied uuid does not exist.
Note: Only the body of the function is to be returned, not the function header.- Parameters:
widgetType
- The type of the widget. This will always conform to the supported widget types that this web widget reports.type
- The type of the attribute. This will never be a type that this web widget has marked as not supported by its isSupported method.refinements
- The refinements to use on this type, mapped to by the uuid of the language of the refinement. If the information in the refinement is necessary to render the attribute, implementations should statically code that information into the returned "function".- Returns:
- a java script function body
-