[Users] Popup
Alex Zeit
zeitalex at googlemail.com
Thu Jun 3 20:51:17 CEST 2010
I found solution using OpenLayers.LoadURL:
var selFeature;
control.events.register("featureselected", this,
function(e) {
var url = '
http://www.domain.com/servlet'+e.feature.attributes.id;
selFeature = e.feature;
OpenLayers.loadURL(url, '', e, createPopup);
OpenLayers.Event.stop(e);
});
var createPopup = function(response) {
popup = new GeoExt.Popup({
title: 'My Popup',
feature: selFeature,
width:200,
html: response.responseText, //
feature.attributes.sid, //bogusMarkup, theHtml
maximizable: false,
collapsible: true
});
2010/6/3 Alex Zeit <zeitalex at googlemail.com>
> Dear All,
> I am trying to create Popup with HTML content that is generated by servlet
> and transferred with XMLHttpRequest.
> Unfortunately the Popup is returned empty. Do I need special
> synchronisation for Popup to wait until request transfer HTML completely?
> (see
> http://hboard.iwk.uni-karlsruhe.de:8080/QuickStartWicket/qswicket/?wicket:bookmarkablePage=:wicketqs.RegioNoGM
> )
> The popup is also looks different from one in example at
> http://dev.geoext.org/trunk/geoext/examples/popup.html
>
>
> select = new OpenLayers.Layer.Vector("Selection", {styleMap:
> new OpenLayers.Style(OpenLayers.Feature.Vector.style["select"])
> });
>
> control = new OpenLayers.Control.GetFeature({
> protocol: new OpenLayers.Protocol.WFS.v1_1_0({...}),
> });
>
> control.events.register("featureselected", this, function(e) {
> select.addFeatures([e.feature]);
> var txt = doRequest('
> http://hboard.iwk.uni-karlsruhe.de:8080/QuickStartWicket-1.0-SNAPSHOT/qswicket/?wicket:bookmarkablePage=:wicketqs.Page1&username='+<http://hboard.iwk.uni-karlsruhe.de:8080/QuickStartWicket-1.0-SNAPSHOT/qswicket/?wicket:bookmarkablePage=:wicketqs.Page1&username=%27+>
> "test");
> createPopup(e.feature, txt);
> });
>
> map.addControl(control);
> control.activate();
>
> function createPopup(feature, htmlText) {
> popup = new GeoExt.Popup({
> title: 'My Popup',
> feature: feature,
> width:200,
> html: htmlText,
> maximizable: false,
> collapsible: true
> });
> popup.show();
> }
>
> function doRequest(servletName){
> var request = addrequest(servletName); //calls
> the addrequest function
> request.onreadystatechange = function(){ //this is used to listen for
> changes in the request's status
> if (request.readyState == 4) {
> if (request.status == 200) {
> var htmlTxt = request.responseText;
> return htmlTxt;
> }
> }
> }
> }
>
> function addrequest(req) {
> var request;
> try { //create a request for
> netscape, mozilla, opera, etc.
> request = new XMLHttpRequest();
> }catch (e) {
>
> try { //create a request for internet
> explorer
> request = new ActiveXObject("Microsoft.XMLHTTP");
> }catch (e) { //do some error-handling
> alert("XMLHttpRequest error: " + e);
> }
> }
>
> request.open("GET", req, true); //prepare the request
> request.send(null); //send it
> return request; //return the request
> }
>
>
> Any help would be highly appreciated
> Alex
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20100603/a02f2bb3/attachment.htm
More information about the Users
mailing list