SWA Gadgets Reference
Version 0.9.0
SWA defines a number of reusable UI gadgets as listed in the index below.
Index
-
arg:classSelectedEvent(xsd:string): The name of the event to publish when the selected class has changed.
-
arg:editable(xsd:boolean): [Optional] True to have buttons to create classes and properties appear under the tree.
-
arg:parentUIElementId(xsd:string): [Optional] HTML element ID for a containing element
-
arg:resourceSelectedEvent(xsd:string): The name of the event to fire if the selected class has changed, but for gadgets that display instances.
-
arg:rootClass(rdfs:Class): The root class of the tree.
-
arg:treeId(xsd:string): [Optional] The (optional) id of the tree, in case someone needs to access it programmatically.
-
arg:classSelectedEvent(xsd:string): The name of the event to publish when the selected class has changed.
-
arg:classTreeDataProvider(swa:TreeDataProvider): An optional data provider for the class tree. If not specified, it will use swa:ClassTreeDataProvider.
-
arg:editable(xsd:boolean): [Optional] True to have a button to create classes appear under the tree.
-
arg:parentUIElementId(xsd:string): [Optional] HTML element ID for a containing element
-
arg:refreshEvent(xsd:string): [Optional] The name of an event that causes the tree to refresh itself.
-
arg:resourceSelectedEvent(xsd:string): The name of the event to fire if the selected class has changed, but for gadgets that display instances.
-
arg:rootClass(rdfs:Class): The root class of the tree.
-
arg:treeId(xsd:string): [Optional] The (optional) id of the tree, in case someone needs to access it programmatically.
-
arg:uiElementId(xsd:string): [Optional] HTML element ID for a containing element
-
arg:classSelectedEvent(xsd:string): [Optional] The name of an event that shall control which class is displayed as root class.
-
arg:parentUIElementId(xsd:string): [Optional] HTML element ID for a containing element
-
arg:resourceType(rdfs:Class): The class to search instances of.
-
arg:searchEvent(xsd:string): [Optional] The name of an event that shall be posted when the search has been updated. This can be used to link this with a results gadget. The data payload of these events will is the URI of a session graph that holds the search:Search object to run – there can only be one such instance in that graph.
Implementation note: The gadget creates a session graph at start-up and reuses that graph for the duration of its existence. Whenever the user clicks the search button, the content of that session graph is completely replaced with a new instance of search:Search, before the search event is published.
-
arg:classSelectedEvent(xsd:string): [Optional] The name of an event that shall control which class is displayed as root class.
-
arg:footerPlugin(swa:SearchFormFooterPlugin): [Optional] An SWP element to appear in the lower right corner.
-
arg:formId(xsd:string): [Optional] The id that shall be used for the new form. The system will generate a unique new id if left blank.
-
arg:hideGlobalSearch(xsd:boolean): [Optional] True to suppress global text search. By default a text field will appear on the top of the form, allowing users to search across all string properties of the given resources. However, this may be slow and can therefore be disabled. If the class being searched over defines swa:textSearchProperties, then the text search will only operate on those explicitly enumerated properties – even if arg:hideGlobalSearch is true.
-
arg:parentUIElementId(xsd:string): [Optional] HTML element ID for a containing element
-
arg:resourceType(rdfs:Class): The class to search instances of.
-
arg:searchButtonHandler(xsd:string): [Optional] The name of a JavaScript function to handle the click event for the Search button.
-
arg:searchEvent(xsd:string): [Optional] The name of an event that shall be posted when the search has been updated. This can be used to link this with a results gadget. The data payload of these events will is the URI of a session graph that holds the search:Search object to run – there can only be one such instance in that graph.
-
arg:suppressActions(xsd:boolean): [Optional] If true, the drop down menu with actions will not appear.
-
arg:suppressKeyPropertiesSelection(xsd:boolean): [Optional] True to disable the check boxes for selecting the result columns.
-
arg:typeSelectable(xsd:boolean): [Optional] True to allow users to switch to the search class using a drop down box.
-
arg:parentUIElementId(xsd:string): [Optional] HTML element ID for a containing element
-
arg:resourceSelectedEvent(xsd:string): The name of an event to publish when the user clicks on a result. The data payload of this event is the URI of the resource.
-
arg:rowNumCookie(xsd:string): [Optional] The name of a cookie remembering the number of rows.
-
arg:searchEvent(xsd:string): [Optional] The name of the event to list to when a search has been triggered. If left blank, then a default event name will be used consistently across all search views.
-
arg:classSelectedEvent(xsd:string): The name of the event to subscribe to so that the instances can be reloaded whenever the class changes.
-
arg:directInstancesOnly(xsd:boolean): [Optional] True to only display the direct instances of the class, i.e. instances of subclasses will not be displayed.
-
arg:editable(xsd:boolean): [Optional] True to have a button to create classes appear under the tree.
-
arg:instanceSelectedEvent(xsd:string): The name of the event to fire if the selected instance has changed.
-
arg:parentUIElementId(xsd:string): [Optional] HTML element ID for a containing element
-
arg:resourceType(rdfs:Class): The class of instances to display.
Note: This gadget is only officially supported if the query graph is backed by a Solr index. The required range queries would be potentially too slow for a pure RDF store.
-
arg:parentUIElementId(xsd:string): [Optional] HTML element ID for a containing element
-
arg:resourceSelectedEvent(xsd:string): The name of an event to publish when the user clicks on a result. The data payload of this event is the URI of the resource.
-
arg:searchEvent(xsd:string): [Optional] The name of the event to list to when a search has been triggered. If left blank, then a default event name will be used consistently across all search views.
-
arg:classSelectedEvent(xsd:string): The name of the event to subscribe to so that the form can be reloaded whenever the class changes.
-
arg:footerPlugin(swa:SearchFormFooterPlugin): [Optional] An SWP element to appear in the lower right corner.
-
arg:formId(xsd:string): [Optional]
-
arg:instanceSelectedEvent(xsd:string): The name of the event to fire if the user has clicked on an instance in the results grid.
-
arg:parentUIElementId(xsd:string): [Optional] HTML element ID for a containing element
-
arg:resourceType(rdfs:Class): The class of instances being searched.
-
arg:resultsId(xsd:string): The id of the matching SearchResultsGridGadget.
-
arg:searchButtonHandler(xsd:string): [Optional] The name of a JavaScript function to handle the click event for the Search button.
-
arg:searchResultsGeneratedEvent(xsd:string): [Optional] The name of an event to fire after search results are generated for the results grid.
-
arg:typeSelectable(xsd:boolean): [Optional] True to allow users to switch to the search class using a drop down box.
-
arg:id(xsd:string): The id of the grid – needed by the search form.
-
arg:parentUIElementId(xsd:string): [Optional] HTML element ID for a containing element
-
arg:parentUIElementId(xsd:string): [Optional] HTML element ID for a containing element
-
arg:resourceSelectedEvent(xsd:string): The name of an event to publish when the user clicks on a result. The data payload of this event is the URI of the resource.
-
arg:searchEvent(xsd:string): [Optional] The name of the event to list to when a search has been triggered. If left blank, then a default event name will be used consistently across all search views.
-
arg:allowHistoryMode(xsd:boolean): [Optional] True to have a “Show history” check box show up in view mode. This mode is currently only supported by the teamwork framework, not general SWA.
-
arg:allowLogMessage(xsd:boolean): [Optional] True to provide an option to enter a log message when saving changes.
-
arg:editing(xsd:boolean): [Optional] True to start in editing mode.
-
arg:footerPlugin(swa:SwitchableFormFooterPlugin): [Optional] An optional component to show up in the lower right corner.
-
arg:parentUIElementId(xsd:string): [Optional] HTML element ID for a containing element
-
arg:readOnly(xsd:boolean): [Optional] True to disallow switching to edit mode.
-
arg:resource(rdfs:Resource): The resource to display.
-
arg:resourceSelectedEvent(xsd:string): The name of the event to subscribe to so that the window can be reloaded if the resource changes. The event will also be re-published whenever the user follows a hyperlink on the form. The data payload of the event needs to be the URI of a resource.
-
arg:showResourceActions(xsd:boolean): [Optional] True to also display a button to run ResourceActions.
-
arg:showURI(xsd:boolean): [Optional] True to include the URI of the resource in the header.
-
arg:parentUIElementId(xsd:string): [Optional] HTML element ID for a containing element
-
arg:resource(rdfs:Resource): The resource to display.
-
arg:resourceSelectedEvent(xsd:string): The name of the event to subscribe to so that the window can be reloaded if the resource changes. The event will also be re-published whenever the user follows a hyperlink on the form. The data payload of the event needs to be the URI of a resource.
Gadget Interactions
A gadget should only interact with other gadgets through an event hub. SWA uses the event hub supported by the OpenSocial standard, which in turn relies on the OpenAjaxHub specification.
In a nutshell, if you want gadget A in your application to change its state wheneverthe user does something in gadget B, then gadget B should publish an event to the hub(using gadgets.Hub.publish()
) and gadget A can “listen” to those events(via gadgets.Hub.subscribe()
). Instead of using these JavaSctipt functions directly, you should use the same patterns employed by the pre-defined gadgets of the SWA library as illustrated by the following example (swadoc:EventsExample
).
1 <swa:FullScreenBorderLayout><swa:Window 2 arg:layoutPanel="west" 3 arg:title="Event Publisher"> 4 <button onclick="{= swa:publishEvent("testEvent", "'World' + Math.random()") }">Click to Send Event</button> 5 </swa:Window> 6 <swa:Window arg:layoutPanel="center" 7 arg:title="Event Subscriber"> 8 <swa:Subscribe arg:code="$('#label').html(data)" 9 arg:event="testEvent"/> 10 <span>Hello </span> 11 <span id="label"/> 12 </swa:Window> 13 </swa:FullScreenBorderLayout>