[fusion-users] Startup widgets possible?
david.wilhelmsson at 65nord.se
david.wilhelmsson at 65nord.se
Fri Sep 7 06:45:06 PDT 2012
For future reference (for people like me who found this post via Google),
using #2, there is one line missing from the widget definition. Here's the
entire definition:
MySelectionHandler.js:
Fusion.Widget.MySelectionHandler = OpenLayers.Class(Fusion.Widget, {
target: null,
url: null,
initializeWidget: function(widgetTag) {
var json = widgetTag.extension;
this.target = json.Target ? json.Target[0] : "TaskPane";
this.url = json.Url ? json.Url[0] : null;
this.getMap().registerForEvent(Fusion.Event.MAP_SELECTION_ON,
OpenLayers.Function.bind(this.selectionOn, this));
this.getMap().registerForEvent(Fusion.Event.MAP_SELECTION_OFF,
OpenLayers.Function.bind(this.selectionOFf, this));
},
selectionOn: function() {
if (this.url) {
var taskPaneTarget = Fusion.getWidgetById(this.target);
if (taskPaneTarget) {
var map = this.getMap();
var mapLayers = map.getAllMaps();
var params = [];
params.push('LOCALE='+Fusion.locale);
params.push('SESSION='+mapLayers[0].getSessionID());
params.push('MAPNAME='+mapLayers[0].getMapName());
params.push('POPUP=false');
var url = this.url;
if (url.indexOf('?') < 0) {
url += '?';
} else if (url.slice(-1) != '&') {
url += '&';
}
url += params.join('&');
taskPaneTarget.setContent(url);
}
}
},
selectionOff: function() {
}
});
Here's a widgetinfo that I created for this widget as well:
MySelectionHandler.xml:
<WidgetInfo>
<Type>MySelectionHandler</Type>
<LocalizedType></LocalizedType>
<Description>A widget to call up a URL on selection</Description>
<Location></Location>
<Label></Label>
<Tooltip></Tooltip>
<StatusText></StatusText>
<ImageUrl></ImageUrl>
<ImageClass></ImageClass>
<StandardUi>true</StandardUi>
<ContainableBy>Any</ContainableBy>
<Parameter>
<Name>Target</Name>
<Description>The frame, window, or TaskPane in which to display any UI for
the widget. If empty, TaskPane is used</Description>
<Type>String</Type>
<Label>Target</Label>
<DefaultValue>TaskPane</DefaultValue>
<IsMandatory>true</IsMandatory>
</Parameter>
<Parameter>
<Name>Url</Name>
<Description>The URL to be opened in the target</Description>
<Type>String</Type>
<Label>Url</Label>
<IsMandatory>true</IsMandatory>
</Parameter>
</WidgetInfo>
Kind regards,
Dave.
--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Startup-widgets-possible-tp3781875p5000444.html
Sent from the Fusion Users mailing list archive at Nabble.com.
More information about the fusion-users
mailing list