The application I am working on needs to perform some SSJS on querySaveDocument of the document. The code it should execute needs to be maintainable without a Designer client (don't ask me why, but it's a customer prerequisite).
The .jss file is stored as file attachment in and I am trying to access it using as a resource of my XPage with a $file url. I tried both http: and notes: with replica id and db path, but the XPages engine can't seem to reference the file.
What would the format be of the "src" attribute if the resource?
Check out this post from Stephan
http://www.wissel.net/blog/d6plinks/SHWL-86QKNM
I think this will help.
I am not sure that this will work. But you could load the library/code with your SSJS or Java method and just do a eval()* or a value binding with the text loaded from your external resource. Then the SSJS code is available for the interpreter and can be executed in the event.
*: eval() is evil! You have been warned!
Related
In XPages, is it possible to call a function in a SSJS library in another database? I'm trying to include a script resource in my custom control that points to a SSJS library in another db. (I'm trying to avoid duplicating the lib by copying it over.) Per this question, I determined the full path to the library by going to the Package Explorer view.
<xp:this.resources>
<xp:script src="picker.nsf/code/scriptlibraries/mylib.jss" clientSide="false" />
</xp:this.resources>
I tried prefixing the path both with and without a \ or / and also propercasing the path, but I continue to get the following runtime error:
Error while executing JavaScript action expression JavaScript library
/picker.nsf/code/scriptlibraries/mylib.jss is not available
I also tried putting copies of picker.nsf in the root (Domino data folder) and in the same subfolder as the primary db but that didn't work.
I think the source question above refers to a .js file that was attached in the files area rather than a code library so it might not apply. Any ideas?
You need to separate the thinking of serverside js and client side js.
Serverside javascript is not "real" javascript like in Node.js, it does only work in the context of a single database and is at runtime running inside the java engine. There might be some OSGI functionality that can inject the code from another database but nothing that is official supported.
Client side javascript is running in the client browser and can access everything that the client browser can access.
I need some enlightenment in using Xpages and Lotusscript.
I have an export button in Xpages, that takes the ID as parameter sends it to Lotus script agent, which than uses that id to fetch data from web service and exports it to .csv.
The agent was tested and is working.
And when i run the Xpages in notes and try to export data it's working, the file is shown in folder that is designed to.
But when the Xpage is running from the browser (chrome, mozilla) and export is pushed nothing happens.
Do i have to use some other way to export data??
Can you give me some explanation how to export data from browsers
I can recommend the POI4XPages project on OpenNTF. Export of views made easy
Where are you testing the agent and where are you looking for the file?
When XPages runs from a browser, all that can ever run on the browser is client-side JavaScript. Any of your back-end code (SSJS etc) runs on the server, the LotusScript agent will also run on the server. So if the LotusScript agent is creating and saving a CSV file to a folder, it will save it to that folder on the server.
Exports running from a browser will typically return HTML or other content that the PC can interpret as needing to be opened in a certain program, e.g. Excel. But you would need to save the code in a Notes Document, then access the document and print the result back to the browser.
There are open source projects like OpenCSV that have Java libraries for outputting a stream of CSV data for a browser. (It's not Apache-licensed, so can't be put on OpenNTF under the Apache license.)
Easiest tweak is to redirect agent's output to "console" - so instead of printing to file (Open File, then Print #1 for example) use ordinary Prints. Also add content-type header.
In XPages you can specify agent's url (http(s)://server/path to nsf/agent?OpenAgent) and browser will get agent's response - what is exactly your CSV. It downloads and opens in Excel, usually.
Make sure to change the security setting of your agent to "Run As a Web User". Otherwise, this agent will not run.
My requirement is when selection of a web resource one HTML page should appear with the content of that web resource.
So I thought I will add a plugin which will get the content of a web resource and dynamically create a HTML page.
now the problems I am having:
1) when the plugin should fire. because it should fire on selection of any web resource, and didn't show web resource in entity list in VS project using developer's tool kit.
2) How I can get the GUID of that selected web resource to get the content.
please guide me how I can do this. Is there any alternate way to do this?
Thank you.
It's a bit unclear what you mean but if I got the nature of your problem correctly, this is the answer to your question.
You're not supposed to use a plugin at all. Since this is an operation on the user interface only, JavaScript is the way to go here. You want to dynamically create contents in a IFRAME component and display those to the user. You should implement onsomeevent method and connect the clicking to fire it.
Accessing web resources is not done by their guids but through their name. At least when trying to access cross frame data stored in such a resource. The name is something that you set yourself when you create or upload the resource to the server.
May be i am wrong about this question.
Using JavaScript, you can achieve this as well.
In JavaScript, access selected WebResource with their name, and you can get details of that WebResourse by making an ActiveXObject.
var JScriptWebResourceUrl = "..Path Of WebResource/jquery.1.4.4.min.js";
var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlHttp.open("GET", JScriptWebResourceUrl, false);
xmlHttp.send();
eval(xmlHttp.responseText);
Now, you can do what you want from here.
Thanks,
Anish
I try to call XSP._isDirty() for XPINC but it does not work. In the browser everything works fine. Is there a trick how i can use it.
Is there a way how i can see clientside errors when i'm executing XPages in the Notesclient?
Two questions here.
Q1. XSP._isDirty()
XSP._isDirty() is an internal call. From the XPages portable command guide (page 156).
XSP._isDirty() : Used internally by the Dirty Save feature— see the <xp:view> properties for enableModifiedFlag. This is a private function.
Code for this call is in the file xspClientDojo.js (look for the uncompressed file on Domino/Notes).
As it is an internal call it is used at risk. There is no guarantee it will work as expected in later versions.
The enableModifiedFlag is an XPage attribute that allows you to mark the page as dirty and prevent the user accidentally leaving the page. There are more details about this on the Infocenter.
Q2. Client side debugging.
You can review client side errors using the developer panel of most modern browsers, or something like the firebug plugin. The XPages extension library comes with a Firebug Lite component you can use as well.
For SSJS and XSP engine issues you can review these in the Notes client by reading the XPages logs in the IBM_TECHNICAL_SUPPORT folder contained in the Notes data folder.
For a "live" method of this is to modify the shortcut that launches notes as follows:
Target: C:\Lotus\Notes\notes.exe -RPARAMS -console -debug -separateSysLogFiles -consoleLog
Start In : C:\Lotus\Notes\framework\
Change the path to match your clients install.
Is it possible to create a document inside document library using just client-side javascript?
Just a simple text or xml file...
There are examples on how to create/delete a folder or delete a file, or update a document property. And you can do anything you want with list items.
But what if I need to create a document in a document or forms library with ECMAScript object model in SP2010, or calling web services via ajax in MOSS? Is it feasible?
Of course you can do it. You just need to have content of file as a Stream or byte[].
Use such code to create file in library.
ok, i found there are multiple ways to do it, though all of them are normally used in desktop apps, not in browser.
Here is the list:
RPC: Simple ajax POSTing to _vti_bin/_vti_aut/author.dll can do the job quickly if you don't need to set metadata or handle multiple content types
Copy Web Service: CopyIntoItems method of copy.asmx service accepts base64-encoded file body
HTTP PUT: You can simply PUT your file to the desired destination, though this method can by unsupported by some browsers