I have an XPage that is saving a document inside SSJS with document1.save(). After this, I call some Java code to do some additional processing of the document and the new data that was saved; I pass document1.getDocument() in to the Java function. In the Java function, it calls Document.save() to save the document again. This seems to be a recipe for getting a save conflict, and I don't know why. Can anyone explain what's happening? TIA! (In addition to understanding why this is happening, if anyone has suggestions for a better way to do what I'm doing, I'd appreciate it.)
Reid
You can use "resolveVariable" in Java to get hold of your NotesXspDocument (which is called DominoDocument in Java). You can then do your save on the DominoDocument object in Java instead of in SSJS.
If you use JSFUtil (which is found in many XPages open source projects) or use your own helper method, you can then do this to get hold of your DominoDocument (replace "currentDocument" with the name of your document data source):
DominoDocument uidoc = (DominoDocument) JSFUtil.resolveVariable("currentDocument");
The resolveVariable method looks like this:
public static Object resolveVariable(final String variable) {
return FacesContext.getCurrentInstance().getApplication().getVariableResolver().resolveVariable(FacesContext.getCurrentInstance(), variable);
}
Related
I figured that the latest build release would allow me to use ejs globally without using node so I tried doing so.
Though, when I try to use ejs.renderFile(params...), i get the error:
TypeError: exports.fileLoader is not a function
Which is just another node module. Is there a way to get around this?
Note: This is the only time we use EJS at my company, so, if not, would you kindly point me in a good direction in how to render .ejs files.
Update: You can create an EJS object by running
new EJS({url: some/url/to/file.ejs}).render({dataToPass: data, moreData: secondData});
yet another way you can use render instead of renderFile, and your ejs file can be get as string:
// here using jQuery
$.get(you_ejs_file_path).then(function (str, status, xhr) {
const html = ejs.render(str, your_data)); // str is ejs file
});
Hi i am new to groovy and i have an issue that i am facing. Currently i am trying to see the values inside typeCache[alias] which seems to be a hashtable.
protected static Hashtable typeCache = new Hashtable();
logger.error "this is type cache : " + typeCache[alias].get(indx)[1];
when i output the element i get the following result in the logs :-
this is type cache : [com.abcd.util.TypeElement#5dc97ce, com.abcd.util.TypeElement#270a8a6, com.abcd.util.TypeElement#5d421487]
am i able to expose further on the elements to see what is in them and what is it doing ?? i am used to php programming and usually in situations such as this i would do a var_dump is there an equivalent of var_dump in groovy ??
thank you.
Each object has a method, which generates a
public String dump()
Generates a detailed dump string of an object showing its class, hashCode and fields. http://docs.groovy-lang.org/latest/html/groovy-jdk/java/lang/Object.html#dump%28%29
This post contains an example, but make sure to read the comment, as the answer is not corrected as of yet.
Can anyone give me at least one idea to how can I connect java with protoge?
how can I access OWL using jena API in java?!
The Jena website has plenty of tutorials available. If you have difficulties getting started, please post the code that does not work and we'll help you along.
First tutorial here
// some definitions
static String personURI = "http://somewhere/JohnSmith";
static String fullName = "John Smith";
// create an empty Model
Model model = ModelFactory.createDefaultModel();
// create the resource
Resource johnSmith = model.createResource(personURI);
// add the property
johnSmith.addProperty(VCARD.FN, fullName);
In order to make this work, you'll need the right imports. Assuming that the Java technicalities are not a problem, this example shows how to create a statement and add it to a model, i.e., an rdf file.
From the same page you can get to more complex material, including OWL tutorials.
You have not mentioned which task you're trying to carry out. Can you describe it?
I've build a method which takes strings as input parameter. In my index.jsp page, I retrieve a GET-variable from the URL using request.getParameter(). Now, I want to call the aforementioned method on this string, but I get a compiler error saying:
The method <method name>(String) is undefined for the type __2F_<webapp name>_2F_src_2F_main_2F_webapp_2F_index_2E_jsp".
Does anyone know why I get this error and how I can get rid of it. Any help is greatly appreciated!
My code is rather lengthy, but I think this is relevant code:
categorie = request.getParameter("categorie");
if (categorie.equals("")) {
categorie = "Category;";
}
ArrayList<String> categorieen = queryCategories(categorie);
You are calling ArrayList<String> categorieen = queryCategories(categorie); and you did not define queryCategories method. Since the JSP page is compiled into a big servlet class, it tries to locate queryCategories method as member of that class and it could not find it.
Very little information. Where is your app deployed? From what I gather, it seems you either haven't restarted the deployed app or have not replaced the changed class file and haven't set some sort of "development mode" on wherein you don't require a restart for a Jsp modification.
Just replace the .jsp and JSP_NAME.class file.
I'm in the process of writing a cleanup routine for a mongodb collection for a unit test via the java driver (i tried the "native" matlab driver but the documentation is, well, scarce).
I can get a connection going (at least i think i can), but i'm stuck at invoking the remove method on a DBCollection object.
I'm running the following code:
javaaddpath(pathToJarFile)
import com.mongodb.*;
mongoClient = MongoClient(mHost);
mongoConn = mongoClient.getDB(dbName);
auth = mongoConn.authenticate(user,password);
events = mongoConn.getCollection('events');
events.remove();
On the last line i get the error
No method 'remove' with matching signature found for class 'com.mongodb.DBCollectionImpl'.
Since i know that the ´remove´ method exists for the DBCollection class, i'm a bit at a loss currently.
Any help would be appreciated. Note that i'm essentially illiterate when it comes to OOP :-S
Edit:
Please note that i also tried
events.remove({});
which results in the same error message.
According to the API documentation of DBCollection.remove, you must provide a DBObject that simply specifies the deletion criteria. It further says to pass an empty document to delete all documents in the collection. At least you must provide an argument.
According to the documentation on how to remove all documents from a collection, you simply pass the argument {} indicating an empty document to that method. So you must call
events.remove( {} );
To answer your question in the comments: The argument must be a DBObject that describes the remove criteria. A cursor is not such a document.
It seems that {} isn't passed correctly by MATLAB, so creating an empty document and passing it to remove does indeed work.
The working code looks like this:
javaaddpath(pathToJarFile)
import com.mongodb.*;
mongoClient = MongoClient(mHost);
mongoConn = mongoClient.getDB(dbName);
auth = mongoConn.authenticate(user,password);
events = mongoConn.getCollection('events');
empty = BasicDBObject();
events.remove(empty);