OpenLayers print map - printing

How can I print a map from the OpenLayers? I want to add print button in my OpenLayers page =) I have MapFish extension for my geoserver, but don`t know how to make request to it. Any other ideas are welcome) Help please.

I had a similar problem using a reverse proxy, because I discovered the answer from info.json contais local ip reference instead of the public url
to solve brutally i replaced the ip referenze with the public url in the ajax request (see the following code. I hope it can be usefull for others...
this.capabilities.createURL = this.capabilities.createURL.replaceAll("192.168.0.0:8080", "mypublicurl");
this.capabilities.printURL= this.capabilities.printURL.replaceAll("192.168.0.0:8080", "mypublicurl");
Ext.Ajax.request({
url:this.capabilities.createURL,
jsonData:jsonData,
success:function(response){
response.responseText = response.responseText.replaceAll("192.168.0.0:8080", "mypublicurl");
window.open(Ext.decode(response.responseText).getURL);
}
});

The simplest way is to use GeoExt.PrintMapPanel (geoext example). And be sure to read GeoServer Printing Module.
UPD GET request example. You must modify url, "baseURL", "layers". If you specify an existing layer, this request must return pdf file.
http://demo.opengeo.org/geoserver/pdf/print.pdf?spec={"units":"degrees","srs":"EPSG:4326","layout":"A4","dpi":75,"mapTitle":"Printing Demo","comment":"This is a simple map printed from GeoExt.","layers":[{"baseURL":"http://demo.opengeo.org/geoserver/wms","opacity":1,"singleTile":true,"type":"WMS","layers":["topp:tasmania_state_boundaries"],"format":"image/jpeg","styles":[""]}],"pages":[{"center":[146.56000000001,-41.56],"scale":8192000,"rotation":0}]}

Related

firefox addon webrequest.addListener misbehaving

I want to examine http requests in an extension for firefox. To begin figuring out how to do what I want to do I figured I'd just log everything and see what comes up:
webRequest.onResponseStarted.addListener(
(stuff) => {console.log(stuff);},
{urls: [/^.*$/]}
);
The domain is insignificant, and I know the regex works, verified in the console. When running this code I get no logging. When I take out the filter parameter I get every request:
webRequest.onResponseStarted.addListener(
(stuff) => {console.log(stuff);}
);
Cool, I'm probably doing something wrong, but I can't see what.
Another approach is to manually filter on my own:
var webRequest = Components.utils.import("resource://gre/modules/WebRequest.jsm", {});
var makeRequest = function(type) {
webRequest[type].addListener(
(stuff) => {
console.log(!stuff.url.match(/google.com.*/));
if(!stuff.url.match(/google.com.*/))
return;
console.log(type);
console.log(stuff);
}
);
}
makeRequest("onBeforeRequest");
makeRequest("onBeforeSentHeaders");
makeRequest("onSendHeaders");
makeRequest("onHeadersReceived");
makeRequest("onResponseStarted");
makeRequest("onCompleted");
With the console.log above the if, I can see the regex returning true when I want it to and the code making it past the if. When I remove the console.log above the if the if no longer gets executed.
My question is then, how do I get the filtering parameter to work or if that is indeed broken, how can I get the code past the if to be executed? Obviously, this is a fire hose, and to begin searching for a solution I will need to reduce the data.
Thanks
urls must be a string or an array of match patterns. Regular expressions are not supported.
WebRequest.jsm uses resource://gre/modules/MatchPattern.jsm. Someone might get confused with the util/match-pattern add-on sdk api, which does support regular expressions.

How to add URL fragment HtmlOutcomeTargetLink?

I would like to add an URL fragment #top to a HtmlOutcomeTargetLink, but cant figure out how. For an HtmlOutputLink I just use the following:
HtmlOutputLink link = new HtmlOutputLink();
String urlWithFragment = url + "#top";
link.setValue(urlWithFragment);
How to acomplish this for a HtmlOutcomeTargetLink?
Unfortunately the following does not work:
HtmlOutcomeTargetLink link = new HtmlOutcomeTargetLink();
String urlWithFragment = context.getViewRoot().getViewId() + "#top";
link.setOutcome(urlWithFragment);
Thanks for your help!
The outcome of HtmlOutcomeTargetLink (the <h:link>) only takes navigation case outcomes, not URLs. The navigation case outcomes do not support URL fragments. Those needs to be set as a separate fragment attribute.
link.setFragment("top");
See also:
<h:link> tag documentation
Update: wait, there's no setter for that on the UIOutcomeTarget parent class. I suspect an oversight in the generated code (funnily it's mentioned here in Mojarra snapshot docs and here in a MyFaces testcase). You should be able to set it directly on the attribute map:
link.getAttributes().put("fragment", "top");

Call javascript in sharepoint custom field

I am creating a custom field in SharePoint 2007. I have seen other solutions where the current site URL was default value of a text field.
How can I get this current site URL?
I have got one answer whiches states that I shall use JavaScript, but where do I put the script?
I hope you can help.
BR
To answer 1
I am new to SharePoint and am not quiet sure where to put the java script. Normaly i just give the initial value to the field in the FieldEditor.cs file but how can I do this with the javascript?
Here follows a picute of my files.
I have tried to put it into FiledEditor.cs but this results in the value of myString is written in the top of the web page.
Here is my current code:
string myScript = "var currentUrl = document.URL; LabelLookupFieldTargetURLText.Text = currentUrl;";
Page.ClientScript.RegisterClientScriptBlock(LabelLookupFieldTargetURLText.GetType(), "LabelLookupFieldTargetURLTextJavaScript", myScript);
I found the answer my self. I don't need to use a java script. I can just use SPContext.Current.Site.Url
use javascript:
var nowUrl = document.URL;
yourTextfiled.value = nowUrl;
you can read this:http://www.w3schools.com/jsref/dom_obj_document.asp

Trying to stream using eventsource through nginx/fastcgi

I am trying to set up an event stream using MVC.NET, Nginx and Fastcgi. The streaming works fine for me using xsp4, but I have not been able to get it to work through Nginx and Fastcgi. My goal is to open an EventSource stream and to downstream data to my website.
I have tried adding the 'ngx_http_upstream_keepalive' module - http://wiki.nginx.org/HttpUpstreamKeepaliveModule - which is funny because there is "Note - this This will not work with HTTP upstreams" in the module description. But wait, isn't that the name of the module? Anyways, maybe I'm confused here. I have also tried adding 'proxy_buffering off' to my nginx.conf, which also hasn't helped.
I understand this should be fairly easy to do, but I am at a loss. Is there some property I can add to my nginx.conf to make this work? Or is there something to add to the Response in .NET?
Please help me StackOverflow!
Based on what I have read here:
http://wiki.nginx.org/X-accel
you need to turn off X-Accel-Buffering. Here is some example code:
public ActionResult Stream(string id)
{
Response.ContentType = "text/event-stream";
Response.Buffer = false;
Response.BufferOutput = false;
Response.Headers["X-Accel-Buffering"] = "no";
return View();
}
Hopefully the code above fixes your problem.

Create tab/window with DOM document instead of URI?

I have a web service that requires special headers to be sent in the request. I am able to retrieve expected responseXMLs using an XMLHttpRequest and setRequestHeader().
Now I would like to create a new tab (or window) containing the response document. I would like the default XMLPrettyPrint.xsl file applied to it and when the source is viewed, I'd like to see the un-styled source as when viewing a normal .xml file.
Any ideas?
I ended up creating a protocol handler.
The biggest trick that I didn't find to be documented well was the fact that the XPCOM contract ID must start with "#mozilla.org/network/protocol;1?name=". E.g.,:
/* as in foo:// . This is called the scheme. */
var thisIsWhatMyProtocolStartsWith = "foo";
var contractID = "#mozilla.org/network/protocol;1?name=" + thisIsWhatMyProtocolStartsWith;

Resources